mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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 {
|
public static class Menus {
|
||||||
[MenuItem("GameObject/Spine/SkeletonRenderer", false, 10)]
|
[MenuItem("GameObject/Spine/SkeletonRenderer", false, 10)]
|
||||||
static public void CreateSkeletonRendererGameObject () {
|
static public void CreateSkeletonRendererGameObject () {
|
||||||
CreateSpineGameObject<SkeletonRenderer>("New SkeletonRenderer");
|
SpineEditorUtilities.EditorInstantiation.InstantiateEmptySpineGameObject<SkeletonRenderer>("New SkeletonRenderer");
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("GameObject/Spine/SkeletonAnimation", false, 10)]
|
[MenuItem("GameObject/Spine/SkeletonAnimation", false, 10)]
|
||||||
static public void CreateSkeletonAnimationGameObject () {
|
static public void CreateSkeletonAnimationGameObject () {
|
||||||
CreateSpineGameObject<SkeletonAnimation>("New SkeletonAnimation");
|
SpineEditorUtilities.EditorInstantiation.InstantiateEmptySpineGameObject<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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1227,6 +1227,17 @@ namespace Spine.Unity.Editor {
|
|||||||
return newSkeletonAnimation;
|
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
|
#region SkeletonMecanim
|
||||||
#if SPINE_SKELETONMECANIM
|
#if SPINE_SKELETONMECANIM
|
||||||
public static SkeletonMecanim InstantiateSkeletonMecanim (SkeletonDataAsset skeletonDataAsset, string skinName) {
|
public static SkeletonMecanim InstantiateSkeletonMecanim (SkeletonDataAsset skeletonDataAsset, string skinName) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user