Browse Source

[unity] Reorganize SpineEditorUtilities.

pharan 7 years ago
parent
commit
dd888a356e

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

@@ -111,7 +111,7 @@ namespace Spine.Unity.Editor {
 				EditorGUILayout.HelpBox(string.Format("Animation named {0} was not found for this Skeleton.", animationNameProperty.stringValue), MessageType.Warning);
 				EditorGUILayout.HelpBox(string.Format("Animation named {0} was not found for this Skeleton.", animationNameProperty.stringValue), MessageType.Warning);
 			} else {
 			} else {
 				using (new SpineInspectorUtility.BoxScope()) {
 				using (new SpineInspectorUtility.BoxScope()) {
-					if (!string.Equals(SpineEditorUtilities.GetPathSafeName(animationName), ThisAnimationReferenceAsset.name, System.StringComparison.OrdinalIgnoreCase))
+					if (!string.Equals(SpineEditorUtilities.AssetUtility.GetPathSafeName(animationName), ThisAnimationReferenceAsset.name, System.StringComparison.OrdinalIgnoreCase))
 						EditorGUILayout.HelpBox("Animation name value does not match this asset's name. Inspectors using this asset may be misleading.", MessageType.None);
 						EditorGUILayout.HelpBox("Animation name value does not match this asset's name. Inspectors using this asset may be misleading.", MessageType.None);
 
 
 					EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(animationName, SpineEditorUtilities.Icons.animation));
 					EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(animationName, SpineEditorUtilities.Icons.animation));

+ 10 - 3
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SkeletonBaker.cs

@@ -30,7 +30,7 @@
 
 
 // Contributed by: Mitch Thompson
 // Contributed by: Mitch Thompson
 
 
-#define SPINE_SKELETON_ANIMATOR
+#define SPINE_SKELETONMECANIM
 
 
 using UnityEngine;
 using UnityEngine;
 using UnityEditor;
 using UnityEditor;
@@ -71,7 +71,14 @@ namespace Spine.Unity.Editor {
 	public static class SkeletonBaker {
 	public static class SkeletonBaker {
 
 
 		#region SkeletonAnimator's Mecanim Clips
 		#region SkeletonAnimator's Mecanim Clips
-		#if SPINE_SKELETON_ANIMATOR
+		#if SPINE_SKELETONMECANIM
+		public static void UpdateMecanimClips (SkeletonDataAsset skeletonDataAsset) {
+			if (skeletonDataAsset.controller == null)
+				return;
+
+			SkeletonBaker.GenerateMecanimAnimationClips(skeletonDataAsset);
+		}
+
 		public static void GenerateMecanimAnimationClips (SkeletonDataAsset skeletonDataAsset) {
 		public static void GenerateMecanimAnimationClips (SkeletonDataAsset skeletonDataAsset) {
 			var data = skeletonDataAsset.GetSkeletonData(true);
 			var data = skeletonDataAsset.GetSkeletonData(true);
 			if (data == null) {
 			if (data == null) {
@@ -1413,7 +1420,7 @@ namespace Spine.Unity.Editor {
 			string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
 			string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
 			string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
 			string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
 			string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
 			string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
-			string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeName(region.name) + ".prefab").Replace("\\", "/");
+			string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.AssetUtility.GetPathSafeName(region.name) + ".prefab").Replace("\\", "/");
 
 
 			GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
 			GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
 			GameObject root;
 			GameObject root;

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

@@ -238,7 +238,7 @@ namespace Spine.Unity.Editor {
 			FieldInfo nameField = typeof(AnimationReferenceAsset).GetField("animationName", BindingFlags.NonPublic | BindingFlags.Instance);
 			FieldInfo nameField = typeof(AnimationReferenceAsset).GetField("animationName", BindingFlags.NonPublic | BindingFlags.Instance);
 			FieldInfo skeletonDataAssetField = typeof(AnimationReferenceAsset).GetField("skeletonDataAsset", BindingFlags.NonPublic | BindingFlags.Instance);
 			FieldInfo skeletonDataAssetField = typeof(AnimationReferenceAsset).GetField("skeletonDataAsset", BindingFlags.NonPublic | BindingFlags.Instance);
 			foreach (var animation in targetSkeletonData.Animations) {
 			foreach (var animation in targetSkeletonData.Animations) {
-				string assetPath = string.Format("{0}/{1}.asset", dataPath, SpineEditorUtilities.GetPathSafeName(animation.Name));
+				string assetPath = string.Format("{0}/{1}.asset", dataPath, SpineEditorUtilities.AssetUtility.GetPathSafeName(animation.Name));
 				AnimationReferenceAsset existingAsset = AssetDatabase.LoadAssetAtPath<AnimationReferenceAsset>(assetPath);
 				AnimationReferenceAsset existingAsset = AssetDatabase.LoadAssetAtPath<AnimationReferenceAsset>(assetPath);
 				if (existingAsset == null) {
 				if (existingAsset == null) {
 					AnimationReferenceAsset newAsset = ScriptableObject.CreateInstance<AnimationReferenceAsset>();
 					AnimationReferenceAsset newAsset = ScriptableObject.CreateInstance<AnimationReferenceAsset>();
@@ -538,8 +538,8 @@ namespace Spine.Unity.Editor {
 				warnings.Add("Missing Skeleton JSON");
 				warnings.Add("Missing Skeleton JSON");
 			} else {
 			} else {
 				var fieldValue = (TextAsset)skeletonJSON.objectReferenceValue;
 				var fieldValue = (TextAsset)skeletonJSON.objectReferenceValue;
-				if (!SpineEditorUtilities.SkeletonDataFileValidator.IsSpineData(fieldValue)) {
-					warnings.Add("Skeleton data file is not a valid JSON or binary file.");
+				if (!SpineEditorUtilities.AssetUtility.IsSpineData(fieldValue)) {
+					warnings.Add("Skeleton data file is not a valid Spine JSON or binary file.");
 				} else {
 				} else {
 					#if SPINE_TK2D
 					#if SPINE_TK2D
 					bool searchForSpineAtlasAssets = true;
 					bool searchForSpineAtlasAssets = true;
@@ -769,7 +769,7 @@ namespace Spine.Unity.Editor {
 
 
 				if (previewGameObject == null) {
 				if (previewGameObject == null) {
 					try {
 					try {
-						previewGameObject = SpineEditorUtilities.InstantiateSkeletonAnimation(skeletonDataAsset, skinName).gameObject;
+						previewGameObject = SpineEditorUtilities.EditorInstantiation.InstantiateSkeletonAnimation(skeletonDataAsset, skinName).gameObject;
 
 
 						if (previewGameObject != null) {
 						if (previewGameObject != null) {
 							previewGameObject.hideFlags = HideFlags.HideAndDontSave;
 							previewGameObject.hideFlags = HideFlags.HideAndDontSave;

+ 4 - 4
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineAtlasAssetInspector.cs

@@ -93,7 +93,7 @@ namespace Spine.Unity.Editor {
 				string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
 				string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
 				for (int i = 0; i < regions.Count; i++) {
 				for (int i = 0; i < regions.Count; i++) {
 					AtlasRegion region = regions[i];
 					AtlasRegion region = regions[i];
-					string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");
+					string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.AssetUtility.GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");
 					GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
 					GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
 					baked.Add(prefab != null);
 					baked.Add(prefab != null);
 					bakedObjects.Add(prefab);
 					bakedObjects.Add(prefab);
@@ -134,12 +134,12 @@ namespace Spine.Unity.Editor {
 			}
 			}
 
 
 			EditorGUILayout.Space();
 			EditorGUILayout.Space();
-			if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Set Mipmap Bias to " + SpineEditorUtilities.DEFAULT_MIPMAPBIAS))) {
+			if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Set Mipmap Bias to " + SpineEditorUtilities.Preferences.DEFAULT_MIPMAPBIAS))) {
 				foreach (var m in atlasAsset.materials) {
 				foreach (var m in atlasAsset.materials) {
 					var texture = m.mainTexture;
 					var texture = m.mainTexture;
-					texture.mipMapBias = SpineEditorUtilities.DEFAULT_MIPMAPBIAS;
+					texture.mipMapBias = SpineEditorUtilities.Preferences.DEFAULT_MIPMAPBIAS;
 				}
 				}
-				Debug.Log("Texture mipmap bias set to " + SpineEditorUtilities.DEFAULT_MIPMAPBIAS);
+				Debug.Log("Texture mipmap bias set to " + SpineEditorUtilities.Preferences.DEFAULT_MIPMAPBIAS);
 			}
 			}
 
 
 			EditorGUILayout.Space();
 			EditorGUILayout.Space();

File diff suppressed because it is too large
+ 657 - 648
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs


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

@@ -193,7 +193,7 @@ namespace Spine.Unity.Editor {
 			}
 			}
 
 
 			skin = skin ?? data.DefaultSkin ?? data.Skins.Items[0];
 			skin = skin ?? data.DefaultSkin ?? data.Skins.Items[0];
-			graphic.MeshGenerator.settings.zSpacing = SpineEditorUtilities.defaultZSpacing;
+			graphic.MeshGenerator.settings.zSpacing = SpineEditorUtilities.Preferences.defaultZSpacing;
 
 
 			graphic.Initialize(false);
 			graphic.Initialize(false);
 			if (skin != null) graphic.Skeleton.SetSkin(skin);
 			if (skin != null) graphic.Skeleton.SetSkin(skin);

Some files were not shown because too many files changed in this diff