static void AddBoneFollowerGameObject(MenuCommand cmd) { var skeletonRenderer = cmd.context as SkeletonRenderer; var go = EditorInstantiation.NewGameObject("New BoneFollower"); var t = go.transform; t.SetParent(skeletonRenderer.transform); t.localPosition = Vector3.zero; var f = go.AddComponent <BoneFollower>(); f.skeletonRenderer = skeletonRenderer; EditorGUIUtility.PingObject(t); Undo.RegisterCreatedObjectUndo(go, "Add BoneFollower"); }
public static void ShowInstantiateContextMenu(SkeletonDataAsset skeletonDataAsset, Vector3 spawnPoint, Transform parent) { var menu = new GenericMenu(); // SkeletonAnimation menu.AddItem(new GUIContent("SkeletonAnimation"), false, HandleSkeletonComponentDrop, new SpawnMenuData { skeletonDataAsset = skeletonDataAsset, spawnPoint = spawnPoint, parent = parent, instantiateDelegate = (data) => EditorInstantiation.InstantiateSkeletonAnimation(data), isUI = false }); // SkeletonGraphic var skeletonGraphicInspectorType = System.Type.GetType("Spine.Unity.Editor.SkeletonGraphicInspector"); if (skeletonGraphicInspectorType != null) { var graphicInstantiateDelegate = skeletonGraphicInspectorType.GetMethod("SpawnSkeletonGraphicFromDrop", BindingFlags.Static | BindingFlags.Public); if (graphicInstantiateDelegate != null) { menu.AddItem(new GUIContent("SkeletonGraphic (UI)"), false, HandleSkeletonComponentDrop, new SpawnMenuData { skeletonDataAsset = skeletonDataAsset, spawnPoint = spawnPoint, parent = parent, instantiateDelegate = System.Delegate.CreateDelegate(typeof(EditorInstantiation.InstantiateDelegate), graphicInstantiateDelegate) as EditorInstantiation.InstantiateDelegate, isUI = true }); } } #if SPINE_SKELETONMECANIM menu.AddSeparator(""); // SkeletonMecanim menu.AddItem(new GUIContent("SkeletonMecanim"), false, HandleSkeletonComponentDrop, new SpawnMenuData { skeletonDataAsset = skeletonDataAsset, spawnPoint = spawnPoint, parent = parent, instantiateDelegate = (data) => EditorInstantiation.InstantiateSkeletonMecanim(data), isUI = false }); #endif menu.ShowAsContext(); }
static void AddBoneFollowerGameObject(MenuCommand cmd) { var skeletonGraphic = cmd.context as SkeletonGraphic; var go = EditorInstantiation.NewGameObject("BoneFollower", true, typeof(RectTransform)); var t = go.transform; t.SetParent(skeletonGraphic.transform); t.localPosition = Vector3.zero; var f = go.AddComponent <BoneFollowerGraphic>(); f.skeletonGraphic = skeletonGraphic; f.SetBone(skeletonGraphic.Skeleton.RootBone.Data.Name); EditorGUIUtility.PingObject(t); Undo.RegisterCreatedObjectUndo(go, "Add BoneFollowerGraphic"); }
static GameObject AddBoundingBoxFollowerChild(SkeletonRenderer sr, BoundingBoxFollower original = null) { var go = EditorInstantiation.NewGameObject("BoundingBoxFollower", true); go.transform.SetParent(sr.transform, false); var newFollower = go.AddComponent <BoundingBoxFollower>(); if (original != null) { newFollower.slotName = original.slotName; newFollower.isTrigger = original.isTrigger; newFollower.clearStateOnDisable = original.clearStateOnDisable; } newFollower.skeletonRenderer = sr; newFollower.Initialize(); Selection.activeGameObject = go; EditorGUIUtility.PingObject(go); return(go); }
static public void CreateSkeletonAnimationGameObject() { EditorInstantiation.InstantiateEmptySpineGameObject <SkeletonAnimation>("New SkeletonAnimation", true); }
static public void CreateSkeletonRendererGameObject() { EditorInstantiation.InstantiateEmptySpineGameObject <SkeletonRenderer>("New SkeletonRenderer", true); }