Browse Source

[unity] New AtlasAssetBase base class.

pharan 7 years ago
parent
commit
41359c12de
19 changed files with 105 additions and 94 deletions
  1. 0 25
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/Menus.cs
  2. 1 1
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/SkeletonDataAssetInspector.cs
  3. 2 2
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/SkeletonRendererInspector.cs
  4. 7 7
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAtlasAssetInspector.cs
  5. 0 0
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAtlasAssetInspector.cs.meta
  6. 2 2
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs
  7. 28 28
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs
  8. 1 1
      spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonGraphic/Editor/SkeletonGraphicInspector.cs
  9. 1 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AnimationReferenceAsset.cs
  10. 15 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AtlasAssetBase.cs
  11. 11 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AtlasAssetBase.cs.meta
  12. 1 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/EventDataReferenceAsset.cs
  13. 5 3
      spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs
  14. 19 12
      spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs
  15. 0 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs.meta
  16. 1 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs
  17. 7 6
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.cs
  18. 3 3
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs
  19. 1 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SlotBlendModes/SlotBlendModes.cs

+ 0 - 25
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Menus.cs

@@ -35,31 +35,6 @@ using UnityEngine;
 
 
 namespace Spine.Unity.Editor {
 namespace Spine.Unity.Editor {
 	public static class Menus {
 	public static class Menus {
-		[MenuItem("Assets/Create/Spine/Atlas Asset")]
-		static public void CreateAtlas () {
-			CreateAsset<AtlasAsset>("New Atlas");
-		}
-
-		[MenuItem("Assets/Create/Spine/SkeletonData Asset")]
-		static public void CreateSkeletonData () {
-			CreateAsset<SkeletonDataAsset>("New SkeletonData");
-		}
-
-		static void CreateAsset<T> (String name) where T : ScriptableObject {
-			var dir = "Assets/";
-			var selected = Selection.activeObject;
-			if (selected != null) {
-				var assetDir = AssetDatabase.GetAssetPath(selected.GetInstanceID());
-				if (assetDir.Length > 0 && Directory.Exists(assetDir))
-					dir = assetDir + "/";
-			}
-			ScriptableObject asset = ScriptableObject.CreateInstance<T>();
-			AssetDatabase.CreateAsset(asset, dir + name + ".asset");
-			AssetDatabase.SaveAssets();
-			EditorUtility.FocusProjectWindow();
-			Selection.activeObject = asset;
-		}
-
 		[MenuItem("GameObject/Spine/SkeletonRenderer", false, 10)]
 		[MenuItem("GameObject/Spine/SkeletonRenderer", false, 10)]
 		static public void CreateSkeletonRendererGameObject () {
 		static public void CreateSkeletonRendererGameObject () {
 			CreateSpineGameObject<SkeletonRenderer>("New SkeletonRenderer");
 			CreateSpineGameObject<SkeletonRenderer>("New SkeletonRenderer");

+ 1 - 1
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SkeletonDataAssetInspector.cs

@@ -332,7 +332,7 @@ namespace Spine.Unity.Editor {
 				else {
 				else {
 					EditorGUILayout.HelpBox("Atlas array should not have null entries!", MessageType.Error);
 					EditorGUILayout.HelpBox("Atlas array should not have null entries!", MessageType.Error);
 					if (SpineInspectorUtility.CenteredButton(SpineInspectorUtility.TempContent("Remove null entries"))) {
 					if (SpineInspectorUtility.CenteredButton(SpineInspectorUtility.TempContent("Remove null entries"))) {
-						var trimmedAtlasAssets = new List<AtlasAsset>();
+						var trimmedAtlasAssets = new List<AtlasAssetBase>();
 						foreach (var a in targetSkeletonDataAsset.atlasAssets) {
 						foreach (var a in targetSkeletonDataAsset.atlasAssets) {
 							if (a != null)
 							if (a != null)
 								trimmedAtlasAssets.Add(a);
 								trimmedAtlasAssets.Add(a);

+ 2 - 2
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SkeletonRendererInspector.cs

@@ -145,7 +145,7 @@ namespace Spine.Unity.Editor {
 						foreach (var c in targets) {
 						foreach (var c in targets) {
 							var component = c as SkeletonRenderer;
 							var component = c as SkeletonRenderer;
 							if (component.skeletonDataAsset != null) {
 							if (component.skeletonDataAsset != null) {
-								foreach (AtlasAsset aa in component.skeletonDataAsset.atlasAssets) {
+								foreach (AtlasAssetBase aa in component.skeletonDataAsset.atlasAssets) {
 									if (aa != null)
 									if (aa != null)
 										aa.Clear();
 										aa.Clear();
 								}
 								}
@@ -192,7 +192,7 @@ namespace Spine.Unity.Editor {
 					if (component.valid) {
 					if (component.valid) {
 						if (GUILayout.Button(ReloadButtonLabel, reloadButtonStyle, reloadWidth)) {
 						if (GUILayout.Button(ReloadButtonLabel, reloadButtonStyle, reloadWidth)) {
 							if (component.skeletonDataAsset != null) {
 							if (component.skeletonDataAsset != null) {
-								foreach (AtlasAsset aa in component.skeletonDataAsset.atlasAssets) {
+								foreach (AtlasAssetBase aa in component.skeletonDataAsset.atlasAssets) {
 									if (aa != null)
 									if (aa != null)
 										aa.Clear();
 										aa.Clear();
 								}
 								}

+ 7 - 7
spine-unity/Assets/Spine/Editor/spine-unity/Editor/AtlasAssetInspector.cs → spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAtlasAssetInspector.cs

@@ -41,10 +41,10 @@ using Spine;
 namespace Spine.Unity.Editor {
 namespace Spine.Unity.Editor {
 	using Event = UnityEngine.Event;
 	using Event = UnityEngine.Event;
 
 
-	[CustomEditor(typeof(AtlasAsset)), CanEditMultipleObjects]
-	public class AtlasAssetInspector : UnityEditor.Editor {
+	[CustomEditor(typeof(SpineAtlasAsset)), CanEditMultipleObjects]
+	public class SpineAtlasAssetInspector : UnityEditor.Editor {
 		SerializedProperty atlasFile, materials;
 		SerializedProperty atlasFile, materials;
-		AtlasAsset atlasAsset;
+		SpineAtlasAsset atlasAsset;
 
 
 		GUIContent spriteSlicesLabel;
 		GUIContent spriteSlicesLabel;
 		GUIContent SpriteSlicesLabel {
 		GUIContent SpriteSlicesLabel {
@@ -72,7 +72,7 @@ namespace Spine.Unity.Editor {
 			atlasFile = serializedObject.FindProperty("atlasFile");
 			atlasFile = serializedObject.FindProperty("atlasFile");
 			materials = serializedObject.FindProperty("materials");
 			materials = serializedObject.FindProperty("materials");
 			materials.isExpanded = true;
 			materials.isExpanded = true;
-			atlasAsset = (AtlasAsset)target;
+			atlasAsset = (SpineAtlasAsset)target;
 			#if REGION_BAKING_MESH
 			#if REGION_BAKING_MESH
 			UpdateBakedList();
 			UpdateBakedList();
 			#endif
 			#endif
@@ -109,7 +109,7 @@ namespace Spine.Unity.Editor {
 			}
 			}
 
 
 			serializedObject.Update();
 			serializedObject.Update();
-			atlasAsset = atlasAsset ?? (AtlasAsset)target;
+			atlasAsset = atlasAsset ?? (SpineAtlasAsset)target;
 			EditorGUI.BeginChangeCheck();
 			EditorGUI.BeginChangeCheck();
 			EditorGUILayout.PropertyField(atlasFile);
 			EditorGUILayout.PropertyField(atlasFile);
 			EditorGUILayout.PropertyField(materials, true);
 			EditorGUILayout.PropertyField(materials, true);
@@ -264,7 +264,7 @@ namespace Spine.Unity.Editor {
 				EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel);
 				EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel);
 				int baseIndent = EditorGUI.indentLevel;
 				int baseIndent = EditorGUI.indentLevel;
 
 
-				var regions = AtlasAssetInspector.GetRegions(atlasAsset.GetAtlas());
+				var regions = SpineAtlasAssetInspector.GetRegions(atlasAsset.GetAtlas());
 				AtlasPage lastPage = null;
 				AtlasPage lastPage = null;
 				for (int i = 0; i < regions.Count; i++) {
 				for (int i = 0; i < regions.Count; i++) {
 					if (lastPage != regions[i].page) {
 					if (lastPage != regions[i].page) {
@@ -302,7 +302,7 @@ namespace Spine.Unity.Editor {
 			var spriteSheet = t.spritesheet;
 			var spriteSheet = t.spritesheet;
 			var sprites = new List<SpriteMetaData>(spriteSheet);
 			var sprites = new List<SpriteMetaData>(spriteSheet);
 
 
-			var regions = AtlasAssetInspector.GetRegions(atlas);
+			var regions = SpineAtlasAssetInspector.GetRegions(atlas);
 			char[] FilenameDelimiter = {'.'};
 			char[] FilenameDelimiter = {'.'};
 			int updatedCount = 0;
 			int updatedCount = 0;
 			int addedCount = 0;
 			int addedCount = 0;

+ 0 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Editor/AtlasAssetInspector.cs.meta → spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAtlasAssetInspector.cs.meta


+ 2 - 2
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAttributeDrawers.cs

@@ -520,7 +520,7 @@ namespace Spine.Unity.Editor {
 			} else if (atlasProp.objectReferenceValue == null) {
 			} else if (atlasProp.objectReferenceValue == null) {
 				EditorGUI.LabelField(position, "ERROR:", "Atlas variable must not be null!");
 				EditorGUI.LabelField(position, "ERROR:", "Atlas variable must not be null!");
 				return;
 				return;
-			} else if (atlasProp.objectReferenceValue.GetType() != typeof(AtlasAsset)) {
+			} else if (atlasProp.objectReferenceValue.GetType() != typeof(AtlasAssetBase)) {
 				EditorGUI.LabelField(position, "ERROR:", "Atlas variable must be of type AtlasAsset!");
 				EditorGUI.LabelField(position, "ERROR:", "Atlas variable must be of type AtlasAsset!");
 			}
 			}
 
 
@@ -533,7 +533,7 @@ namespace Spine.Unity.Editor {
 
 
 		void Selector (SerializedProperty property) {
 		void Selector (SerializedProperty property) {
 			GenericMenu menu = new GenericMenu();
 			GenericMenu menu = new GenericMenu();
-			AtlasAsset atlasAsset = (AtlasAsset)atlasProp.objectReferenceValue;
+			AtlasAssetBase atlasAsset = (AtlasAssetBase)atlasProp.objectReferenceValue;
 			Atlas atlas = atlasAsset.GetAtlas();
 			Atlas atlas = atlasAsset.GetAtlas();
 			FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
 			FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
 			List<AtlasRegion> regions = (List<AtlasRegion>)field.GetValue(atlas);
 			List<AtlasRegion> regions = (List<AtlasRegion>)field.GetValue(atlas);

+ 28 - 28
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs

@@ -657,10 +657,10 @@ namespace Spine.Unity.Editor {
 			}
 			}
 
 
 			// Import atlases first.
 			// Import atlases first.
-			var atlases = new List<AtlasAsset>();
+			var atlases = new List<AtlasAssetBase>();
 			foreach (string ap in atlasPaths) {
 			foreach (string ap in atlasPaths) {
 				TextAsset atlasText = (TextAsset)AssetDatabase.LoadAssetAtPath(ap, typeof(TextAsset));
 				TextAsset atlasText = (TextAsset)AssetDatabase.LoadAssetAtPath(ap, typeof(TextAsset));
-				AtlasAsset atlas = IngestSpineAtlas(atlasText);
+				AtlasAssetBase atlas = IngestSpineAtlas(atlasText);
 				atlases.Add(atlas);
 				atlases.Add(atlas);
 			}
 			}
 
 
@@ -696,7 +696,7 @@ namespace Spine.Unity.Editor {
 						switch (result) {
 						switch (result) {
 						case -1:
 						case -1:
 							//Debug.Log("Select Atlas");
 							//Debug.Log("Select Atlas");
-							AtlasAsset selectedAtlas = GetAtlasDialog(Path.GetDirectoryName(sp));
+							AtlasAssetBase selectedAtlas = GetAtlasDialog(Path.GetDirectoryName(sp));
 							if (selectedAtlas != null) {
 							if (selectedAtlas != null) {
 								localAtlases.Clear();
 								localAtlases.Clear();
 								localAtlases.Add(selectedAtlas);
 								localAtlases.Add(selectedAtlas);
@@ -758,14 +758,14 @@ namespace Spine.Unity.Editor {
 						// and as a result, all comparisons with null returns true.
 						// and as a result, all comparisons with null returns true.
 						// But the C# wrapper is still alive, so we can "restore" the object
 						// But the C# wrapper is still alive, so we can "restore" the object
 						// by reloading it from its Instance ID.
 						// by reloading it from its Instance ID.
-						AtlasAsset[] skeletonDataAtlasAssets = skeletonDataAsset.atlasAssets;
+						AtlasAssetBase[] skeletonDataAtlasAssets = skeletonDataAsset.atlasAssets;
 						if (skeletonDataAtlasAssets != null) {
 						if (skeletonDataAtlasAssets != null) {
 							for (int i = 0; i < skeletonDataAtlasAssets.Length; i++) {
 							for (int i = 0; i < skeletonDataAtlasAssets.Length; i++) {
 								if (!ReferenceEquals(null, skeletonDataAtlasAssets[i]) &&
 								if (!ReferenceEquals(null, skeletonDataAtlasAssets[i]) &&
 									skeletonDataAtlasAssets[i].Equals(null) &&
 									skeletonDataAtlasAssets[i].Equals(null) &&
 									skeletonDataAtlasAssets[i].GetInstanceID() != 0
 									skeletonDataAtlasAssets[i].GetInstanceID() != 0
 								) {
 								) {
-									skeletonDataAtlasAssets[i] = EditorUtility.InstanceIDToObject(skeletonDataAtlasAssets[i].GetInstanceID()) as AtlasAsset;
+									skeletonDataAtlasAssets[i] = EditorUtility.InstanceIDToObject(skeletonDataAtlasAssets[i].GetInstanceID()) as AtlasAssetBase;
 								}
 								}
 							}
 							}
 						}
 						}
@@ -792,8 +792,8 @@ namespace Spine.Unity.Editor {
 		#region Match SkeletonData with Atlases
 		#region Match SkeletonData with Atlases
 		static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh };
 		static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh };
 
 
-		static List<AtlasAsset> MultiAtlasDialog (List<string> requiredPaths, string initialDirectory, string filename = "") {
-			List<AtlasAsset> atlasAssets = new List<AtlasAsset>();
+		static List<AtlasAssetBase> MultiAtlasDialog (List<string> requiredPaths, string initialDirectory, string filename = "") {
+			List<AtlasAssetBase> atlasAssets = new List<AtlasAssetBase>();
 			bool resolved = false;
 			bool resolved = false;
 			string lastAtlasPath = initialDirectory;
 			string lastAtlasPath = initialDirectory;
 			while (!resolved) {
 			while (!resolved) {
@@ -845,7 +845,7 @@ namespace Spine.Unity.Editor {
 
 
 				switch (result) {
 				switch (result) {
 				case 0: // Browse...
 				case 0: // Browse...
-					AtlasAsset selectedAtlasAsset = GetAtlasDialog(lastAtlasPath);
+					AtlasAssetBase selectedAtlasAsset = GetAtlasDialog(lastAtlasPath);
 					if (selectedAtlasAsset != null) {
 					if (selectedAtlasAsset != null) {
 						var atlas = selectedAtlasAsset.GetAtlas();
 						var atlas = selectedAtlasAsset.GetAtlas();
 						bool hasValidRegion = false;
 						bool hasValidRegion = false;
@@ -871,19 +871,19 @@ namespace Spine.Unity.Editor {
 			return atlasAssets;
 			return atlasAssets;
 		}
 		}
 
 
-		static AtlasAsset GetAtlasDialog (string dirPath) {
+		static AtlasAssetBase GetAtlasDialog (string dirPath) {
 			string path = EditorUtility.OpenFilePanel("Select AtlasAsset...", dirPath, "asset");
 			string path = EditorUtility.OpenFilePanel("Select AtlasAsset...", dirPath, "asset");
 			if (path == "") return null; // Canceled or closed by user.
 			if (path == "") return null; // Canceled or closed by user.
 
 
 			int subLen = Application.dataPath.Length - 6;
 			int subLen = Application.dataPath.Length - 6;
 			string assetRelativePath = path.Substring(subLen, path.Length - subLen).Replace("\\", "/");
 			string assetRelativePath = path.Substring(subLen, path.Length - subLen).Replace("\\", "/");
 
 
-			Object obj = AssetDatabase.LoadAssetAtPath(assetRelativePath, typeof(AtlasAsset));
+			Object obj = AssetDatabase.LoadAssetAtPath(assetRelativePath, typeof(AtlasAssetBase));
 
 
-			if (obj == null || obj.GetType() != typeof(AtlasAsset))
+			if (obj == null || obj.GetType() != typeof(AtlasAssetBase))
 				return null;
 				return null;
 
 
-			return (AtlasAsset)obj;
+			return (AtlasAssetBase)obj;
 		}
 		}
 
 
 		static void AddRequiredAtlasRegionsFromBinary (string skeletonDataPath, List<string> requiredPaths) {
 		static void AddRequiredAtlasRegionsFromBinary (string skeletonDataPath, List<string> requiredPaths) {
@@ -945,10 +945,10 @@ namespace Spine.Unity.Editor {
 			return requiredPaths;
 			return requiredPaths;
 		}
 		}
 
 
-		static AtlasAsset GetMatchingAtlas (List<string> requiredPaths, List<AtlasAsset> atlasAssets) {
-			AtlasAsset atlasAssetMatch = null;
+		static AtlasAssetBase GetMatchingAtlas (List<string> requiredPaths, List<AtlasAssetBase> atlasAssets) {
+			AtlasAssetBase atlasAssetMatch = null;
 
 
-			foreach (AtlasAsset a in atlasAssets) {
+			foreach (AtlasAssetBase a in atlasAssets) {
 				Atlas atlas = a.GetAtlas();
 				Atlas atlas = a.GetAtlas();
 				bool failed = false;
 				bool failed = false;
 				foreach (string regionPath in requiredPaths) {
 				foreach (string regionPath in requiredPaths) {
@@ -1003,23 +1003,23 @@ namespace Spine.Unity.Editor {
 		#endregion
 		#endregion
 
 
 		#region Import Atlases
 		#region Import Atlases
-		static List<AtlasAsset> FindAtlasesAtPath (string path) {
-			List<AtlasAsset> arr = new List<AtlasAsset>();
+		static List<AtlasAssetBase> FindAtlasesAtPath (string path) {
+			List<AtlasAssetBase> arr = new List<AtlasAssetBase>();
 			DirectoryInfo dir = new DirectoryInfo(path);
 			DirectoryInfo dir = new DirectoryInfo(path);
 			FileInfo[] assetInfoArr = dir.GetFiles("*.asset");
 			FileInfo[] assetInfoArr = dir.GetFiles("*.asset");
 
 
 			int subLen = Application.dataPath.Length - 6;
 			int subLen = Application.dataPath.Length - 6;
 			foreach (var f in assetInfoArr) {
 			foreach (var f in assetInfoArr) {
 				string assetRelativePath = f.FullName.Substring(subLen, f.FullName.Length - subLen).Replace("\\", "/");
 				string assetRelativePath = f.FullName.Substring(subLen, f.FullName.Length - subLen).Replace("\\", "/");
-				Object obj = AssetDatabase.LoadAssetAtPath(assetRelativePath, typeof(AtlasAsset));
+				Object obj = AssetDatabase.LoadAssetAtPath(assetRelativePath, typeof(AtlasAssetBase));
 				if (obj != null)
 				if (obj != null)
-					arr.Add(obj as AtlasAsset);
+					arr.Add(obj as AtlasAssetBase);
 			}
 			}
 
 
 			return arr;
 			return arr;
 		}
 		}
 
 
-		static AtlasAsset IngestSpineAtlas (TextAsset atlasText) {
+		static AtlasAssetBase IngestSpineAtlas (TextAsset atlasText) {
 			if (atlasText == null) {
 			if (atlasText == null) {
 				Debug.LogWarning("Atlas source cannot be null!");
 				Debug.LogWarning("Atlas source cannot be null!");
 				return null;
 				return null;
@@ -1030,12 +1030,12 @@ namespace Spine.Unity.Editor {
 
 
 			string atlasPath = assetPath + "/" + primaryName + "_Atlas.asset";
 			string atlasPath = assetPath + "/" + primaryName + "_Atlas.asset";
 
 
-			AtlasAsset atlasAsset = (AtlasAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAsset));
+			SpineAtlasAsset atlasAsset = (SpineAtlasAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(SpineAtlasAsset));
 
 
 			List<Material> vestigialMaterials = new List<Material>();
 			List<Material> vestigialMaterials = new List<Material>();
 
 
 			if (atlasAsset == null)
 			if (atlasAsset == null)
-				atlasAsset = AtlasAsset.CreateInstance<AtlasAsset>();
+				atlasAsset = SpineAtlasAsset.CreateInstance<SpineAtlasAsset>();
 			else {
 			else {
 				foreach (Material m in atlasAsset.materials)
 				foreach (Material m in atlasAsset.materials)
 					vestigialMaterials.Add(m);
 					vestigialMaterials.Add(m);
@@ -1146,12 +1146,12 @@ namespace Spine.Unity.Editor {
 			}
 			}
 
 
 			protectFromStackGarbageCollection.Remove(atlasAsset);
 			protectFromStackGarbageCollection.Remove(atlasAsset);
-			return (AtlasAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAsset));
+			return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase));
 		}
 		}
 		#endregion
 		#endregion
 
 
 		#region Bake Atlas Region
 		#region Bake Atlas Region
-		public static GameObject BakeRegion (AtlasAsset atlasAsset, AtlasRegion region, bool autoSave = true) {
+		public static GameObject BakeRegion (SpineAtlasAsset atlasAsset, AtlasRegion region, bool autoSave = true) {
 			Atlas atlas = atlasAsset.GetAtlas();
 			Atlas atlas = atlasAsset.GetAtlas();
 			string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
 			string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
 			string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
 			string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
@@ -1198,7 +1198,7 @@ namespace Spine.Unity.Editor {
 
 
 		#region Import SkeletonData (json or binary)
 		#region Import SkeletonData (json or binary)
 		public const string SkeletonDataSuffix = "_SkeletonData";
 		public const string SkeletonDataSuffix = "_SkeletonData";
-		static SkeletonDataAsset IngestSpineProject (TextAsset spineJson, params AtlasAsset[] atlasAssets) {
+		static SkeletonDataAsset IngestSpineProject (TextAsset spineJson, params AtlasAssetBase[] atlasAssets) {
 			string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
 			string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
 			string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
 			string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
 			string filePath = assetPath + "/" + primaryName + SkeletonDataSuffix + ".asset";
 			string filePath = assetPath + "/" + primaryName + SkeletonDataSuffix + ".asset";
@@ -1363,7 +1363,7 @@ namespace Spine.Unity.Editor {
 
 
 			bool pmaVertexColors = false;
 			bool pmaVertexColors = false;
 			bool tintBlack = false;
 			bool tintBlack = false;
-			foreach (AtlasAsset atlasAsset in skeletonDataAsset.atlasAssets) {
+			foreach (SpineAtlasAsset atlasAsset in skeletonDataAsset.atlasAssets) {
 				if (!pmaVertexColors) {
 				if (!pmaVertexColors) {
 					foreach (Material m in atlasAsset.materials) {
 					foreach (Material m in atlasAsset.materials) {
 						if (m.shader.name.Contains(PMAShaderQuery)) {
 						if (m.shader.name.Contains(PMAShaderQuery)) {
@@ -1399,7 +1399,7 @@ namespace Spine.Unity.Editor {
 			if (data == null) {
 			if (data == null) {
 				for (int i = 0; i < skeletonDataAsset.atlasAssets.Length; i++) {
 				for (int i = 0; i < skeletonDataAsset.atlasAssets.Length; i++) {
 					string reloadAtlasPath = AssetDatabase.GetAssetPath(skeletonDataAsset.atlasAssets[i]);
 					string reloadAtlasPath = AssetDatabase.GetAssetPath(skeletonDataAsset.atlasAssets[i]);
-					skeletonDataAsset.atlasAssets[i] = (AtlasAsset)AssetDatabase.LoadAssetAtPath(reloadAtlasPath, typeof(AtlasAsset));
+					skeletonDataAsset.atlasAssets[i] = (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(reloadAtlasPath, typeof(AtlasAssetBase));
 				}
 				}
 				data = skeletonDataAsset.GetSkeletonData(false);
 				data = skeletonDataAsset.GetSkeletonData(false);
 			}
 			}
@@ -1476,7 +1476,7 @@ namespace Spine.Unity.Editor {
 			if (data == null) {
 			if (data == null) {
 				for (int i = 0; i < skeletonDataAsset.atlasAssets.Length; i++) {
 				for (int i = 0; i < skeletonDataAsset.atlasAssets.Length; i++) {
 					string reloadAtlasPath = AssetDatabase.GetAssetPath(skeletonDataAsset.atlasAssets[i]);
 					string reloadAtlasPath = AssetDatabase.GetAssetPath(skeletonDataAsset.atlasAssets[i]);
-					skeletonDataAsset.atlasAssets[i] = (AtlasAsset)AssetDatabase.LoadAssetAtPath(reloadAtlasPath, typeof(AtlasAsset));
+					skeletonDataAsset.atlasAssets[i] = (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(reloadAtlasPath, typeof(AtlasAssetBase));
 				}
 				}
 				data = skeletonDataAsset.GetSkeletonData(true);
 				data = skeletonDataAsset.GetSkeletonData(true);
 			}
 			}

+ 1 - 1
spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonGraphic/Editor/SkeletonGraphicInspector.cs

@@ -186,7 +186,7 @@ namespace Spine.Unity.Editor {
 			if (data == null) {
 			if (data == null) {
 				for (int i = 0; i < skeletonDataAsset.atlasAssets.Length; i++) {
 				for (int i = 0; i < skeletonDataAsset.atlasAssets.Length; i++) {
 					string reloadAtlasPath = AssetDatabase.GetAssetPath(skeletonDataAsset.atlasAssets[i]);
 					string reloadAtlasPath = AssetDatabase.GetAssetPath(skeletonDataAsset.atlasAssets[i]);
-					skeletonDataAsset.atlasAssets[i] = (AtlasAsset)AssetDatabase.LoadAssetAtPath(reloadAtlasPath, typeof(AtlasAsset));
+					skeletonDataAsset.atlasAssets[i] = (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(reloadAtlasPath, typeof(AtlasAssetBase));
 				}
 				}
 
 
 				data = skeletonDataAsset.GetSkeletonData(true);
 				data = skeletonDataAsset.GetSkeletonData(true);

+ 1 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AnimationReferenceAsset.cs

@@ -33,7 +33,7 @@
 using UnityEngine;
 using UnityEngine;
 
 
 namespace Spine.Unity {
 namespace Spine.Unity {
-	[CreateAssetMenu(menuName = "Spine/Animation Reference Asset")]
+	[CreateAssetMenu(menuName = "Spine/Animation Reference Asset", order = 100)]
 	public class AnimationReferenceAsset : ScriptableObject, IHasSkeletonDataAsset {
 	public class AnimationReferenceAsset : ScriptableObject, IHasSkeletonDataAsset {
 		const bool QuietSkeletonData = true;
 		const bool QuietSkeletonData = true;
 
 

+ 15 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AtlasAssetBase.cs

@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Spine.Unity {
+	public abstract class AtlasAssetBase : ScriptableObject {
+		public abstract Material PrimaryMaterial { get; }
+		public abstract IEnumerable<Material> Materials { get; }
+		public abstract int MaterialCount { get; }
+
+		public abstract bool IsLoaded { get; }
+		public abstract void Clear ();
+		public abstract Atlas GetAtlas ();
+	}
+}

+ 11 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AtlasAssetBase.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 787a36933c1c6e14db2104c01ed92dcb
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/EventDataReferenceAsset.cs

@@ -33,7 +33,7 @@
 using UnityEngine;
 using UnityEngine;
 
 
 namespace Spine.Unity {
 namespace Spine.Unity {
-	[CreateAssetMenu(menuName = "Spine/EventData Reference Asset")]
+	[CreateAssetMenu(menuName = "Spine/EventData Reference Asset", order = 100)]
 	public class EventDataReferenceAsset : ScriptableObject {
 	public class EventDataReferenceAsset : ScriptableObject {
 		const bool QuietSkeletonData = true;
 		const bool QuietSkeletonData = true;
 
 

+ 5 - 3
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs

@@ -34,9 +34,11 @@ using UnityEngine;
 using Spine;
 using Spine;
 
 
 namespace Spine.Unity {
 namespace Spine.Unity {
+
+	[CreateAssetMenu(fileName = "New SkeletonDataAsset", menuName = "Spine/SkeletonData Asset")]
 	public class SkeletonDataAsset : ScriptableObject {
 	public class SkeletonDataAsset : ScriptableObject {
 		#region Inspector
 		#region Inspector
-		public AtlasAsset[] atlasAssets = new AtlasAsset[0];
+		public AtlasAssetBase[] atlasAssets = new AtlasAssetBase[0];
 		#if SPINE_TK2D
 		#if SPINE_TK2D
 		public tk2dSpriteCollectionData spriteCollection;
 		public tk2dSpriteCollectionData spriteCollection;
 		public float scale = 1f;
 		public float scale = 1f;
@@ -65,13 +67,13 @@ namespace Spine.Unity {
 		#region Runtime Instantiation
 		#region Runtime Instantiation
 		/// <summary>
 		/// <summary>
 		/// Creates a runtime SkeletonDataAsset.</summary>
 		/// Creates a runtime SkeletonDataAsset.</summary>
-		public static SkeletonDataAsset CreateRuntimeInstance (TextAsset skeletonDataFile, AtlasAsset atlasAsset, bool initialize, float scale = 0.01f) {
+		public static SkeletonDataAsset CreateRuntimeInstance (TextAsset skeletonDataFile, AtlasAssetBase atlasAsset, bool initialize, float scale = 0.01f) {
 			return CreateRuntimeInstance(skeletonDataFile, new [] {atlasAsset}, initialize, scale);
 			return CreateRuntimeInstance(skeletonDataFile, new [] {atlasAsset}, initialize, scale);
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>
 		/// Creates a runtime SkeletonDataAsset.</summary>
 		/// Creates a runtime SkeletonDataAsset.</summary>
-		public static SkeletonDataAsset CreateRuntimeInstance (TextAsset skeletonDataFile, AtlasAsset[] atlasAssets, bool initialize, float scale = 0.01f) {
+		public static SkeletonDataAsset CreateRuntimeInstance (TextAsset skeletonDataFile, AtlasAssetBase[] atlasAssets, bool initialize, float scale = 0.01f) {
 			SkeletonDataAsset skeletonDataAsset = ScriptableObject.CreateInstance<SkeletonDataAsset>();
 			SkeletonDataAsset skeletonDataAsset = ScriptableObject.CreateInstance<SkeletonDataAsset>();
 			skeletonDataAsset.Clear();
 			skeletonDataAsset.Clear();
 			skeletonDataAsset.skeletonJSON = skeletonDataFile;
 			skeletonDataAsset.skeletonJSON = skeletonDataFile;

+ 19 - 12
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AtlasAsset.cs → spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs

@@ -36,18 +36,23 @@ using Spine;
 
 
 namespace Spine.Unity {
 namespace Spine.Unity {
 	/// <summary>Loads and stores a Spine atlas and list of materials.</summary>
 	/// <summary>Loads and stores a Spine atlas and list of materials.</summary>
-	public class AtlasAsset : ScriptableObject {
+	[CreateAssetMenu(fileName = "New Spine Atlas Asset", menuName = "Spine/Spine Atlas Asset")]
+	public class SpineAtlasAsset : AtlasAssetBase {
 		public TextAsset atlasFile;
 		public TextAsset atlasFile;
 		public Material[] materials;
 		public Material[] materials;
 		protected Atlas atlas;
 		protected Atlas atlas;
 
 
-		public bool IsLoaded { get { return this.atlas != null; } }
+		public override bool IsLoaded { get { return this.atlas != null; } }
 
 
+		public override IEnumerable<Material> Materials { get { return materials; } }
+		public override int MaterialCount { get { return materials == null ? 0 : materials.Length; } }
+		public override Material PrimaryMaterial { get { return materials[0]; } }
+		
 		#region Runtime Instantiation
 		#region Runtime Instantiation
 		/// <summary>
 		/// <summary>
 		/// Creates a runtime AtlasAsset</summary>
 		/// Creates a runtime AtlasAsset</summary>
-		public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Material[] materials, bool initialize) {
-			AtlasAsset atlasAsset = ScriptableObject.CreateInstance<AtlasAsset>();
+		public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Material[] materials, bool initialize) {
+			SpineAtlasAsset atlasAsset = ScriptableObject.CreateInstance<SpineAtlasAsset>();
 			atlasAsset.Reset();
 			atlasAsset.Reset();
 			atlasAsset.atlasFile = atlasText;
 			atlasAsset.atlasFile = atlasText;
 			atlasAsset.materials = materials;
 			atlasAsset.materials = materials;
@@ -59,8 +64,8 @@ namespace Spine.Unity {
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>
-		/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
-		public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) {
+		/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.SpineAtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
+		public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) {
 			// Get atlas page names.
 			// Get atlas page names.
 			string atlasString = atlasText.text;
 			string atlasString = atlasText.text;
 			atlasString = atlasString.Replace("\r", "");
 			atlasString = atlasString.Replace("\r", "");
@@ -98,8 +103,8 @@ namespace Spine.Unity {
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>
-		/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
-		public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) {
+		/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAssetBase.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
+		public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) {
 			if (shader == null)
 			if (shader == null)
 				shader = Shader.Find("Spine/Skeleton");
 				shader = Shader.Find("Spine/Skeleton");
 
 
@@ -110,16 +115,18 @@ namespace Spine.Unity {
 		}
 		}
 		#endregion
 		#endregion
 
 
+
+
 		void Reset () {
 		void Reset () {
 			Clear();
 			Clear();
 		}
 		}
 
 
-		public virtual void Clear () {
+		public override void Clear () {
 			atlas = null;
 			atlas = null;
 		}
 		}
 
 
 		/// <returns>The atlas or null if it could not be loaded.</returns>
 		/// <returns>The atlas or null if it could not be loaded.</returns>
-		public virtual Atlas GetAtlas () {
+		public override Atlas GetAtlas () {
 			if (atlasFile == null) {
 			if (atlasFile == null) {
 				Debug.LogError("Atlas file not set for atlas asset: " + name, this);
 				Debug.LogError("Atlas file not set for atlas asset: " + name, this);
 				Clear();
 				Clear();
@@ -204,9 +211,9 @@ namespace Spine.Unity {
 	}
 	}
 
 
 	public class MaterialsTextureLoader : TextureLoader {
 	public class MaterialsTextureLoader : TextureLoader {
-		AtlasAsset atlasAsset;
+		SpineAtlasAsset atlasAsset;
 
 
-		public MaterialsTextureLoader (AtlasAsset atlasAsset) {
+		public MaterialsTextureLoader (SpineAtlasAsset atlasAsset) {
 			this.atlasAsset = atlasAsset;
 			this.atlasAsset = atlasAsset;
 		}
 		}
 
 

+ 0 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/AtlasAsset.cs.meta → spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs.meta


+ 1 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs

@@ -244,7 +244,7 @@ namespace Spine.Unity {
 
 
 			if (this.singleSubmesh) {
 			if (this.singleSubmesh) {
 				// STEP 1. Determine a SmartMesh.Instruction. Split up instructions into submeshes. =============================================
 				// STEP 1. Determine a SmartMesh.Instruction. Split up instructions into submeshes. =============================================
-				MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, skeleton, skeletonDataAsset.atlasAssets[0].materials[0]);
+				MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, skeleton, skeletonDataAsset.atlasAssets[0].PrimaryMaterial);
 
 
 				// STEP 1.9. Post-process workingInstructions. ==================================================================================
 				// STEP 1.9. Post-process workingInstructions. ==================================================================================
 				#if SPINE_OPTIONAL_MATERIALOVERRIDE
 				#if SPINE_OPTIONAL_MATERIALOVERRIDE

+ 7 - 6
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.cs

@@ -51,14 +51,15 @@ namespace Spine.Unity.Modules {
 
 
 			// Populate atlas list 
 			// Populate atlas list 
 			if (skeletonRenderer != null && skeletonRenderer.skeletonDataAsset != null) {
 			if (skeletonRenderer != null && skeletonRenderer.skeletonDataAsset != null) {
-				AtlasAsset[] atlasAssets = skeletonRenderer.skeletonDataAsset.atlasAssets;
+				var atlasAssets = skeletonRenderer.skeletonDataAsset.atlasAssets;
 
 
 				var initialAtlasMaterialOverrides = new List<AtlasMaterialOverride>();
 				var initialAtlasMaterialOverrides = new List<AtlasMaterialOverride>();
-				foreach (AtlasAsset atlasAsset in atlasAssets) {
-					foreach (Material atlasMaterial in atlasAsset.materials) {
-						var atlasMaterialOverride = new AtlasMaterialOverride();
-						atlasMaterialOverride.overrideDisabled = true;
-						atlasMaterialOverride.originalMaterial = atlasMaterial;
+				foreach (AtlasAssetBase atlasAsset in atlasAssets) {
+					foreach (Material atlasMaterial in atlasAsset.Materials) {
+						var atlasMaterialOverride = new AtlasMaterialOverride {
+							overrideDisabled = true,
+							originalMaterial = atlasMaterial
+						};
 
 
 						initialAtlasMaterialOverrides.Add(atlasMaterialOverride);
 						initialAtlasMaterialOverrides.Add(atlasMaterialOverride);
 					}
 					}

+ 3 - 3
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs

@@ -64,7 +64,7 @@ namespace Spine.Unity {
 					Clear();
 					Clear();
 					Initialize(true);
 					Initialize(true);
 					startingAnimation = "";
 					startingAnimation = "";
-					if (skeletonDataAsset.atlasAssets.Length > 1 || skeletonDataAsset.atlasAssets[0].materials.Length > 1)
+					if (skeletonDataAsset.atlasAssets.Length > 1 || skeletonDataAsset.atlasAssets[0].MaterialCount > 1)
 						Debug.LogError("Unity UI does not support multiple textures per Renderer. Your skeleton will not be rendered correctly. Recommend using SkeletonAnimation instead. This requires the use of a Screen space camera canvas.");
 						Debug.LogError("Unity UI does not support multiple textures per Renderer. Your skeleton will not be rendered correctly. Recommend using SkeletonAnimation instead. This requires the use of a Screen space camera canvas.");
 				} else {
 				} else {
 					if (freeze) return;
 					if (freeze) return;
@@ -136,7 +136,7 @@ namespace Spine.Unity {
 			get { 
 			get { 
 				// Fail loudly when incorrectly set up.
 				// Fail loudly when incorrectly set up.
 				if (overrideTexture != null) return overrideTexture;
 				if (overrideTexture != null) return overrideTexture;
-				return skeletonDataAsset == null ? null : skeletonDataAsset.atlasAssets[0].materials[0].mainTexture;
+				return skeletonDataAsset == null ? null : skeletonDataAsset.atlasAssets[0].PrimaryMaterial.mainTexture;
 			}
 			}
 		}
 		}
 
 
@@ -224,7 +224,7 @@ namespace Spine.Unity {
 			var skeletonData = this.skeletonDataAsset.GetSkeletonData(false);
 			var skeletonData = this.skeletonDataAsset.GetSkeletonData(false);
 			if (skeletonData == null) return;
 			if (skeletonData == null) return;
 
 
-			if (skeletonDataAsset.atlasAssets.Length <= 0 || skeletonDataAsset.atlasAssets[0].materials.Length <= 0) return;
+			if (skeletonDataAsset.atlasAssets.Length <= 0 || skeletonDataAsset.atlasAssets[0].MaterialCount <= 0) return;
 
 
 			this.state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
 			this.state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
 			if (state == null) {
 			if (state == null) {

+ 1 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SlotBlendModes/SlotBlendModes.cs

@@ -141,7 +141,7 @@ namespace Spine.Unity.Modules {
 				var sr = GetComponent<SkeletonRenderer>(); if (sr == null) return;
 				var sr = GetComponent<SkeletonRenderer>(); if (sr == null) return;
 				var sda = sr.skeletonDataAsset; if (sda == null) return;
 				var sda = sr.skeletonDataAsset; if (sda == null) return;
 				var aa = sda.atlasAssets[0]; if (aa == null) return;
 				var aa = sda.atlasAssets[0]; if (aa == null) return;
-				var am = aa.materials[0]; if (am == null) return;
+				var am = aa.PrimaryMaterial; if (am == null) return;
 				texture = am.mainTexture as Texture2D;
 				texture = am.mainTexture as Texture2D;
 			}
 			}
 		}
 		}