Exemplo n.º 1
0
        void LoadPartAnim()
        {
            var skeletonAnimation = EditorInstantiation.InstantiateSkeletonAnimation(editPartDef.skeletonDataAsset);

            skeletonAnimation.gameObject.name = $"{editPartDef.name}_{editPartDef.partType}";
            partInfo.partAnim = skeletonAnimation;

            var seletonRenderSeparator = skeletonAnimation.gameObject.AddComponent <SkeletonRenderSeparator>();

//            seletonRenderSeparator.partsRenderers
            AddPartsRenderer(seletonRenderSeparator, 1);
            DetectOrphanedPartsRenderers(seletonRenderSeparator);

//            foreach (var slot in skeleton.DrawOrder) {
//	            var slotNames = SkeletonRendererInspector.GetSeparatorSlotNames(skeletonRenderer);
//	            for (int i = 0, n = slotNames.Length; i < n; i++) {
//		            if (string.Equals(slotNames[i], slot.Data.Name, System.StringComparison.Ordinal)) {
//			            EditorGUILayout.LabelField(SeparatorString);
//			            break;
//		            }
//	            }
//	            using (new EditorGUI.DisabledScope(!slot.Bone.Active)) {
//		            EditorGUILayout.LabelField(
//			            SpineInspectorUtility.TempContent(slot.Data.Name, Icons.slot),
//			            GUILayout.ExpandWidth(false));
//	            }
//            }
        }
Exemplo n.º 2
0
            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();
            }