mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-10 17:18:44 +08:00
[unity] Move instantiation code.
This commit is contained in:
parent
c81f9dbe62
commit
9eba3e1bbd
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user