Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed VisibilityToggle exception in Unity 2018.3 #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Editor/Psd2UnityImporter-Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Psd2UnityImporter-Editor",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}
3 changes: 3 additions & 0 deletions Editor/Psd2UnityImporter-Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Editor/PsdImportWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,19 @@ private void LoadStyles()
fontStyle = FontStyle.Bold
};

// XXX: VisibilityToggle style is not exists in Unity 2018.3
#if UNITY_2018_3_OR_NEWER
tempStyle = new GUIStyle()
{
normal = new GUIStyleState() { background = EditorGUIUtility.Load("Icons/animationvisibilitytoggleoff.png") as Texture2D },
onNormal = new GUIStyleState() { background = EditorGUIUtility.Load("Icons/animationvisibilitytoggleon.png") as Texture2D },
fixedHeight = 11, fixedWidth = 13,
border = new RectOffset(2, 2, 2, 2), overflow = new RectOffset(-1, 1, -2, 2), padding = new RectOffset(3, 3, 3, 3), richText = false,
stretchHeight = false, stretchWidth = false,
};
#else
tempStyle = GUI.skin.FindStyle("VisibilityToggle");
#endif

styleVisOff = new GUIStyle(tempStyle)
{
Expand Down
4 changes: 2 additions & 2 deletions Editor/PsdImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private static Texture2D GetLayerTexture(PsdDocument psdDoc, PsdLayer psdLayer,
return layerTexture;
}

private static Texture2D GetTexture(PsdLayer layer)
public static Texture2D GetTexture(PsdLayer layer)
{
Texture2D texture = new Texture2D(layer.Width, layer.Height);
Color32[] pixels = new Color32[layer.Width * layer.Height];
Expand Down Expand Up @@ -629,4 +629,4 @@ public static Vector2 AlignmentToPivot(SpriteAlignment spriteAlignment)
}
#endregion
}
}
}