Пример #1
0
        private void BaseSkillInput(SkillData currSkillData)
        {
            #region 基本

            MyGUIExtend.Instance.Foldout("基本" + this.currSkillData.id + currSkillData.id, "基本", () =>
            {
                currSkillData.name   = MyGUI.TextFieldWithTitle("name", currSkillData.name);
                MonoScript component =
                    (MonoScript)AssetDatabase.LoadAssetAtPath(currSkillData.componentPath, typeof(MonoScript));
                component = (UnityEditor.MonoScript)EditorGUILayout.ObjectField(new GUIContent("脚本"),
                                                                                component, typeof(UnityEditor.MonoScript), true);

                if (component != null)
                {
                    currSkillData.componentPath     = AssetDatabase.GetAssetPath(component);
                    currSkillData.componentTypeName =
                        component.GetClass().Namespace + "." + component.GetClass().Name;
                }
                currSkillData.SurvivalTime = MyGUI.FloatFieldWithTitle("存活时间", currSkillData.SurvivalTime);

                // 朝向模式 add by TangJian 2019/4/20 13:24
                currSkillData.SkillOrientationMode =
                    (SkillOrientationMode)MyGUI.EnumPopupWithTitle("朝向模式",
                                                                   currSkillData.SkillOrientationMode);
            });

            #endregion

            #region 渲染

            MyGUIExtend.Instance.Foldout("渲染" + this.currSkillData.id + currSkillData.id, "渲染", () =>
            {
                currSkillData.rendererType =
                    (RendererType)MyGUI.EnumPopupWithTitle("rander类型:", currSkillData.rendererType);
                switch (currSkillData.rendererType)
                {
                case RendererType.SkeletonAnimator:
                    {
                        Spine.Unity.SkeletonDataAsset SkeletonDataAsset =
                            (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(
                                currSkillData.SkeletonDataAssetPath, typeof(Spine.Unity.SkeletonDataAsset));
                        UnityEditor.Animations.AnimatorController animatorController =
                            (UnityEditor.Animations.AnimatorController)AssetDatabase.LoadAssetAtPath(
                                currSkillData.AnimControllerPath,
                                typeof(UnityEditor.Animations.AnimatorController));
                        animatorController =
                            (UnityEditor.Animations.AnimatorController)EditorGUILayout.ObjectField(
                                new GUIContent("动画控制器"), animatorController,
                                typeof(UnityEditor.Animations.AnimatorController), true);
                        SkeletonDataAsset =
                            (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField(
                                new GUIContent("Skeleton"), SkeletonDataAsset,
                                typeof(Spine.Unity.SkeletonDataAsset), true);
                        currSkillData.SkeletonDataAssetPath = AssetDatabase.GetAssetPath(SkeletonDataAsset);
                        currSkillData.AnimControllerPath    = AssetDatabase.GetAssetPath(animatorController);
                        if (SkeletonDataAsset != null)
                        {
                            string[] skins =
                                new string[SkeletonDataAsset.GetSkeletonData(false).Skins.Count];
                            int skinIndex = 0;
                            for (int i = 0; i < skins.Length; i++)
                            {
                                string skinNameString = SkeletonDataAsset.GetSkeletonData(false).Skins
                                                        .Items[i].Name;
                                skins[i] = skinNameString;
                                if (skinNameString == currSkillData.SkinName)
                                {
                                    skinIndex = i;
                                }
                            }

                            skinIndex = EditorGUILayout.Popup("Initial Skin(皮肤)", skinIndex, skins);
                            currSkillData.SkinName = skins[skinIndex];
                        }
                    }
                    break;

                case RendererType.Sprite:
                    {
                        currSkillData.SpritePath =
                            MyGUI.ObjectField <Sprite>("精灵: ", currSkillData.SpritePath);
                    }
                    break;

                case RendererType.Skeleton:
                    Spine.Unity.SkeletonDataAsset skeletonDataAsset = AssetDatabase.LoadAssetAtPath <Spine.Unity.SkeletonDataAsset>(currSkillData.SkeletonPath);
                    skeletonDataAsset          = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField("Skeleton", skeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset));
                    currSkillData.SkeletonPath = AssetDatabase.GetAssetPath(skeletonDataAsset);

                    if (skeletonDataAsset != null)
                    {
                        if (skeletonDataAsset != null && skeletonDataAsset.GetSkeletonData(false) != null && skeletonDataAsset.GetSkeletonData(false).Animations != null)
                        {
                            string[] Animations = new string[skeletonDataAsset.GetSkeletonData(false).Animations.Count];
                            int skinIndex       = 0;
                            for (int i = 0; i < Animations.Length; i++)
                            {
                                string skinNameString = skeletonDataAsset.GetSkeletonData(false).Animations.Items[i].Name;
                                Animations[i]         = skinNameString;
                                if (skinNameString == currSkillData.SkeletonClipName)
                                {
                                    skinIndex = i;
                                }
                            }
                            skinIndex = EditorGUILayout.Popup("Animation(动画片段)", skinIndex, Animations);
                            currSkillData.SkeletonClipName = Animations[skinIndex];
                        }
                    }
                    break;

                case RendererType.Anim:
                    currSkillData.AnimName = EditorGUILayout.TextField("AnimName:", currSkillData.AnimName);
                    break;

                default:
                    Debug.Log("UnKnown:" + currSkillData.rendererType);
                    break;
                }

                currSkillData.shadow = MyGUI.ToggleWithTitle("阴影", currSkillData.shadow);
                if (currSkillData.shadow)
                {
                    currSkillData.shadowScale =
                        MyGUI.Vector3WithTitle("阴影scale", currSkillData.shadowScale);
                    currSkillData.CutOffDistance =
                        MyGUI.FloatFieldWithTitle("阴影CutOffDistance", currSkillData.CutOffDistance);
                    currSkillData.MaxScaleMultpler = MyGUI.FloatFieldWithTitle("阴影MaxScaleMultpler",
                                                                               currSkillData.MaxScaleMultpler);
                }
            });
            #endregion
        }