Эх сурвалжийг харах

[unity] Move instantiation code.

pharan 7 жил өмнө
parent
commit
9eba3e1bbd

+ 2 - 13
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Menus.cs

@@ -37,23 +37,12 @@ namespace Spine.Unity.Editor {
 	public static class Menus {
 		[MenuItem("GameObject/Spine/SkeletonRenderer", false, 10)]
 		static public void CreateSkeletonRendererGameObject () {
-			CreateSpineGameObject<SkeletonRenderer>("New SkeletonRenderer");
+			SpineEditorUtilities.EditorInstantiation.InstantiateEmptySpineGameObject<SkeletonRenderer>("New SkeletonRenderer");
 		}
 
 		[MenuItem("GameObject/Spine/SkeletonAnimation", false, 10)]
 		static public void CreateSkeletonAnimationGameObject () {
-			CreateSpineGameObject<SkeletonAnimation>("New SkeletonAnimation");
-		}
-
-		static void CreateSpineGameObject<T> (string name) where T : MonoBehaviour {
-			var parentGameObject = Selection.activeObject as GameObject;
-			var parentTransform = parentGameObject == null ? null : parentGameObject.transform;
-
-			var gameObject = new GameObject(name, typeof(T));
-			gameObject.transform.SetParent(parentTransform, false);
-			EditorUtility.FocusProjectWindow();
-			Selection.activeObject = gameObject;
-			EditorGUIUtility.PingObject(Selection.activeObject);
+			SpineEditorUtilities.EditorInstantiation.InstantiateEmptySpineGameObject<SkeletonAnimation>("New SkeletonAnimation");
 		}
 	}
 }

+ 11 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs

@@ -1227,6 +1227,17 @@ namespace Spine.Unity.Editor {
 				return newSkeletonAnimation;
 			}
 
+			public static void InstantiateEmptySpineGameObject<T> (string name) where T : MonoBehaviour {
+				var parentGameObject = Selection.activeObject as GameObject;
+				var parentTransform = parentGameObject == null ? null : parentGameObject.transform;
+
+				var gameObject = new GameObject(name, typeof(T));
+				gameObject.transform.SetParent(parentTransform, false);
+				EditorUtility.FocusProjectWindow();
+				Selection.activeObject = gameObject;
+				EditorGUIUtility.PingObject(Selection.activeObject);
+			}
+
 			#region SkeletonMecanim
 			#if SPINE_SKELETONMECANIM
 			public static SkeletonMecanim InstantiateSkeletonMecanim (SkeletonDataAsset skeletonDataAsset, string skinName) {