From 9bb546c6d66eb989f44db3d3a3fed72d66b69618 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 27 Sep 2016 01:45:44 +0800 Subject: [PATCH] [unity] Restored AtlasAsset inspector region list. --- .../Asset Types/Editor/AtlasAssetInspector.cs | 72 +++++++++++++++---- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs b/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs index 4531e5be8..1b05236aa 100644 --- a/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs +++ b/spine-unity/Assets/spine-unity/Asset Types/Editor/AtlasAssetInspector.cs @@ -56,6 +56,13 @@ namespace Spine.Unity.Editor { UpdateBakedList(); #endif } + + private List Regions { + get { + FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.NonPublic); + return (List)field.GetValue(atlasAsset.GetAtlas()); + } + } #if REGION_BAKING_MESH private List baked; @@ -92,8 +99,7 @@ namespace Spine.Unity.Editor { var spriteSheet = t.spritesheet; var sprites = new List(spriteSheet); - FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.NonPublic); - var regions = (List)field.GetValue(atlas); + var regions = this.Regions; int textureHeight = texture.height; char[] FilenameDelimiter = {'.'}; int updatedCount = 0; @@ -168,20 +174,27 @@ namespace Spine.Unity.Editor { } } + EditorGUILayout.Space(); if (atlasFile.objectReferenceValue != null) { - if (GUILayout.Button( - new GUIContent( - "Apply Regions as Texture Sprite Slices", - "Adds Sprite slices to atlas texture(s). " + - "Updates existing slices if ones with matching names exist. \n\n" + - "If your atlas was exported with Premultiply Alpha, " + - "your SpriteRenderer should use the generated Spine _Material asset (or any Material with a PMA shader) instead of Sprites-Default.") - , GUILayout.Height(70f))) { - var atlas = atlasAsset.GetAtlas(); - foreach (var m in atlasAsset.materials) - UpdateSpriteSlices(m.mainTexture, atlas); + using (new EditorGUILayout.HorizontalScope()) { + EditorGUILayout.Space(); + if (GUILayout.Button( + new GUIContent( + "Apply Regions as Texture Sprite Slices", + SpineEditorUtilities.Icons.unityIcon, + "Adds Sprite slices to atlas texture(s). " + + "Updates existing slices if ones with matching names exist. \n\n" + + "If your atlas was exported with Premultiply Alpha, " + + "your SpriteRenderer should use the generated Spine _Material asset (or any Material with a PMA shader) instead of Sprites-Default.") + , GUILayout.Height(30f))) { + var atlas = atlasAsset.GetAtlas(); + foreach (var m in atlasAsset.materials) + UpdateSpriteSlices(m.mainTexture, atlas); + } + EditorGUILayout.Space(); } } + EditorGUILayout.Space(); #if REGION_BAKING_MESH if (atlasFile.objectReferenceValue != null) { @@ -289,6 +302,39 @@ namespace Spine.Unity.Editor { #endif } + #else + if (atlasFile.objectReferenceValue != null) { + EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel); + + var regions = this.Regions; + AtlasPage lastPage = null; + for (int i = 0; i < regions.Count; i++) { + if (lastPage != regions[i].page) { + if (lastPage != null) { + EditorGUILayout.Separator(); + EditorGUILayout.Separator(); + } + lastPage = regions[i].page; + Material mat = ((Material)lastPage.rendererObject); + if (mat != null) { + + GUILayout.BeginHorizontal(); + { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250)); + EditorGUI.EndDisabledGroup(); + EditorGUI.indentLevel++; + } + GUILayout.EndHorizontal(); + + } else { + EditorGUILayout.LabelField(new GUIContent("Page missing material!", SpineEditorUtilities.Icons.warning)); + } + } + EditorGUILayout.LabelField(new GUIContent(regions[i].name, SpineEditorUtilities.Icons.image)); + } + EditorGUI.indentLevel--; + } #endif if (serializedObject.ApplyModifiedProperties() ||