Exemplo n.º 1
0
        //加载动作
        private void LoadAnimationState(bool force = true)
        {
            SkillArt skillart  = EditorDataContainer.currentskillAssetData.skillArt;
            string   modelName = "";

            modelName = skillart.modelName;
            RuntimeAnimatorController controller0 = AssetUtility.GetAnimationCtl(skillart.modelType, skillart.modelName, skillart.animationController);

            if (skillart.animationControllerObj == null && controller0 != null)
            {
                skillart.animationControllerObj = controller0;
            }
            RuntimeAnimatorController controller = skillart.animationControllerObj;// AssetUtility.GetAnimationCtl(skillart.modelType, modelName, skillart.animationController);

            if (force && controller == null)
            {
                Debug.Log("Error! Error animationController Not Found");
            }
            if (controller != null)
            {
                if (force)
                {
                    stateNamelist = new List <string>();
                    stateNamelist = MecanimAnimationUtility.GetAllStateNamesWithController(controller);
                }
                else
                {
                    if (stateNamelist == null)
                    {
                        stateNamelist = new List <string>();
                        stateNamelist = MecanimAnimationUtility.GetAllStateNamesWithController(controller);
                    }
                }
            }
            else if (stateNamelist == null)
            {
                stateNamelist = new List <string>();
            }
            else if (stateNamelist != null)
            {
                stateNamelist.Clear();
            }
        }
Exemplo n.º 2
0
        private void OnGUI()
        {
            if (m_Editor == null)
            {
                // 第一个参数这里暂时没关系,因为编辑器没有取目标对象
                m_Editor = (PreviewExampleInspector)Editor.CreateEditor(this, typeof(PreviewExampleInspector));
            }
            ModelTargetType modelType = EditorDataContainer.currentskillAssetData.skillArt.modelType;
            GameObject      model     = EditorDataContainer.currentskillAssetData.skillArt.model;

            EditorGUILayout.BeginVertical();

            int newtypeindex = EditorGUILayout.Popup("ModelType:", (int)modelType, Enum.GetNames(typeof(ModelTargetType)));

            if (newtypeindex != (int)modelType)
            {
                EditorDataContainer.currentskillAssetData.skillArt.modelType = (ModelTargetType)newtypeindex;
            }
            List <GameObject> allFbx      = AssetUtility.GetAllFBXWithType((ModelTargetType)newtypeindex);
            List <string>     fbxNamelist = new List <string>();

            for (int i = 0; i < allFbx.Count; i++)
            {
                fbxNamelist.Add(allFbx[i].name);
            }
            int fbxselet = -1;

            if (model != null)
            {
                if (fbxNamelist.Contains(model.name))
                {
                    fbxselet = fbxNamelist.IndexOf(model.name);
                }
            }
            int newselectfbx = EditorGUILayout.Popup(fbxselet, fbxNamelist.ToArray());

            if (newselectfbx != fbxselet)
            {
                EditorDataContainer.currentskillAssetData.skillArt.model = allFbx[newselectfbx];
            }
            GameObject NewFbx = (GameObject)EditorGUILayout.ObjectField("Model:", model, typeof(GameObject), true);

            if (NewFbx != model)
            {
                EditorDataContainer.currentskillAssetData.skillArt.model     = NewFbx;
                EditorDataContainer.currentskillAssetData.skillArt.modelName = EditorDataContainer.currentskillAssetData.skillArt.model.name;
            }
            if (EditorDataContainer.currentskillAssetData.skillArt.model != null)
            {
                EditorDataContainer.currentskillAssetData.skillArt.modelName = EditorDataContainer.currentskillAssetData.skillArt.model.name;

                EditorDataContainer.currentskillAssetData.skillArt.animationController = EditorDataContainer.currentskillAssetData.skillArt.model.name + "_Anim";
                EditorGUILayout.TextField("animationControllerName", EditorDataContainer.currentskillAssetData.skillArt.animationController);
                RuntimeAnimatorController controller = AssetUtility.GetAnimationCtl(EditorDataContainer.currentskillAssetData.skillArt.modelType, EditorDataContainer.currentskillAssetData.skillArt.modelName, EditorDataContainer.currentskillAssetData.skillArt.animationController);

                if (EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj == null && controller != null)
                {
                    EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj = controller;
                }

                RuntimeAnimatorController newcontroller = (RuntimeAnimatorController)EditorGUILayout.ObjectField("AnimatorController:", EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj, typeof(RuntimeAnimatorController), true);
                if (newcontroller != controller)
                {
                    EditorDataContainer.currentskillAssetData.skillArt.animationController    = newcontroller.name;
                    EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj = newcontroller;
                }
            }
            if (GUILayout.Button("Create Empty Skill"))
            {
                EditorDataContainer.CreateEmptySkill("NewSkill", EditorDataContainer.currentskillAssetData.skillArt.model, EditorDataContainer.currentskillAssetData.skillArt.modelType, EditorDataContainer.currentskillAssetData.skillArt.animationControllerObj);
            }
            if (EditorDataContainer.currentskillAssetData.skillArt.model != null)
            {
                //Texture pre = AssetPreview.GetAssetPreview(EditorDataContainer.currentskillAssetData.skillArt.model);
                GUILayout.Label("");
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.width     = position.width;
                rect.height    = position.height - rect.y;
                m_Editor.model = EditorDataContainer.currentskillAssetData.skillArt.model;
                //   EditorGUI.DrawPreviewTexture(rect, pre);
                m_Editor.DrawPreview(rect);
            }
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 3
0
        //绘制特效信息
        public void DrawSkillArtEffect(SkillArt skillart, float width)
        {
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Skill ArtEffect: 特效");
            //id
            if (skillart.idString == "")
            {
                skillart.idString = EditorDrawUtility.GetSkillStringById(skillart.id);
            }
            string id = EditorGUILayout.TextField("Id:", skillart.idString);

            if (id != skillart.idString)
            {
                skillart.idString = id;
                skillart.id       = EditorDrawUtility.GetSkillIdByString(id);
            }
            //modelType
            int typeindex    = (int)skillart.modelType;
            int newtypeindex = EditorGUILayout.Popup("ModelTargetType:", typeindex, Enum.GetNames(typeof(ModelTargetType)));

            if (newtypeindex != typeindex)
            {
                skillart.modelType = (ModelTargetType)newtypeindex;
                allFbx             = null;
                LoadFbx();
            }
            int fbxselet = -1;
            // GameObject fbx = AssetUtility.GetFBXWithName(EditorDataContainer.currentskillAssetData.modelName);
            GameObject fbx = EditorDataContainer.currentskillAssetData.skillArt.model;

            if (fbx != null)
            {
                if (fbxNamelist.Contains(fbx.name))
                {
                    fbxselet = fbxNamelist.IndexOf(fbx.name);
                }
            }
            LoadAnimationState(false);
            EditorGUILayout.BeginHorizontal();
            GameObject NewFbx       = (GameObject)EditorGUILayout.ObjectField("Model:", fbx, typeof(GameObject), true);
            int        newselectfbx = EditorGUILayout.Popup(fbxselet, fbxNamelist.ToArray());

            EditorGUILayout.EndHorizontal();
            if (newselectfbx != fbxselet)
            {
                skillart.model               = allFbx[newselectfbx];
                skillart.modelName           = allFbx[newselectfbx].name;
                skillart.animationController = allFbx[newselectfbx].name + "_Anim";
                LoadAnimationState();
                SkillEffectPrefabs = null;
                LoadEffect();
            }
            else
            {
                if (NewFbx == null)
                {
                    skillart.model               = null;
                    skillart.modelName           = "";
                    skillart.animationController = "";
                }
                else if (NewFbx != skillart.model)
                {
                    skillart.model               = NewFbx;
                    skillart.modelName           = NewFbx.name;
                    skillart.animationController = NewFbx.name + "_Anim";
                    LoadAnimationState();
                    SkillEffectPrefabs = null;
                    LoadEffect();
                }
            }
            EditorGUILayout.TextField("animationControllerName:", skillart.animationController);
            RuntimeAnimatorController controller = AssetUtility.GetAnimationCtl(skillart.modelType, skillart.modelName, skillart.animationController);

            if (skillart.animationControllerObj == null && controller != null)
            {
                skillart.animationControllerObj = controller;
            }

            RuntimeAnimatorController newcontroller = (RuntimeAnimatorController)EditorGUILayout.ObjectField("AnimatorController:", skillart.animationControllerObj, typeof(RuntimeAnimatorController), true);

            if (newcontroller != controller)
            {
                skillart.animationController    = newcontroller.name;
                skillart.animationControllerObj = newcontroller;
                LoadAnimationState();
            }

            EditorGUILayout.LabelField("GuideAction 开始动作:");
            skillart.guideFadeTime = EditorGUILayout.FloatField("  guideFadeTime:", skillart.guideFadeTime);
            EditorDrawUtility.DrawActionRect("  guideAction:", skillart.guideAction, out skillart.guideAction, stateNamelist);
            EditorDrawUtility.DrawActionRect("  guidingAction:", skillart.guidingAction, out skillart.guidingAction, stateNamelist);
            EditorDrawUtility.DrawActionRect("  endAction:", skillart.endAction, out skillart.endAction, stateNamelist);


            showBeginEffect = EditorGUILayout.Foldout(showBeginEffect, "beginEffect 起手特效:");
            //EditorGUILayout.LabelField("beginEffect 起手特效:");
            if (showBeginEffect)
            {
                if (skillart.beginEffect != null)
                {
                    EditorDrawUtility.DrawEffectUnitList(skillart.beginEffect, beginScrollPos, out beginScrollPos, width, ref beginEffectList, effectNamelist, SkillEffectPrefabs);
                }
                else
                {
                    if (GUILayout.Button("Add beginEffectList"))
                    {
                        skillart.beginEffect = new List <SkillEffectUnit>();
                    }
                }
            }
            showEndEffect = EditorGUILayout.Foldout(showEndEffect, "endEffect 结束特效:");
            // EditorGUILayout.LabelField("tipEffect 警告特效:");
            if (showEndEffect)
            {
                if (skillart.endEffect != null)
                {
                    EditorDrawUtility.DrawEffectUnitList(skillart.endEffect, endEffectScrollPos, out endEffectScrollPos, width, ref endEffectList, effectNamelist, SkillEffectPrefabs);
                }
                else
                {
                    if (GUILayout.Button("Add endEffectList"))
                    {
                        skillart.endEffect = new List <SkillEffectUnit>();
                    }
                }
            }
            showUnit = EditorGUILayout.Foldout(showUnit, "unitEffect 弹道特效:");
            //EditorGUILayout.LabelField("unitEffect 弹道特效:");
            if (showUnit)
            {
                if (skillart.unitEffect != null)
                {
                    EditorDrawUtility.DrawEffectUnitList(skillart.unitEffect, unitEffectScrollPos, out unitEffectScrollPos, width, ref unitEffectList, effectNamelist, SkillEffectPrefabs);
                }
                else
                {
                    if (GUILayout.Button("Add unitEffectList"))
                    {
                        skillart.unitEffect = new List <SkillEffectUnit>();
                    }
                }
            }

            showTipEffect = EditorGUILayout.Foldout(showTipEffect, "tipEffect 警告特效:");
            // EditorGUILayout.LabelField("tipEffect 警告特效:");
            if (showTipEffect)
            {
                if (skillart.tipEffect != null)
                {
                    EditorDrawUtility.DrawEffectUnitList(skillart.tipEffect, tipEffectScrollPos, out tipEffectScrollPos, width, ref tipEffectList, effectNamelist, SkillEffectPrefabs);
                }
                else
                {
                    if (GUILayout.Button("Add tipEffectList"))
                    {
                        skillart.tipEffect = new List <SkillEffectUnit>();
                    }
                }
            }
            showHitEffect = EditorGUILayout.Foldout(showHitEffect, "hitEffect 击中特效:");
            // EditorGUILayout.LabelField("tipEffect 警告特效:");
            if (showHitEffect)
            {
                if (skillart.hitEffect != null)
                {
                    EditorDrawUtility.DrawEffectUnitList(skillart.hitEffect, hitEffectScrollPos, out hitEffectScrollPos, width, ref hitEffectList, effectNamelist, SkillEffectPrefabs);
                }
                else
                {
                    if (GUILayout.Button("Add hitEffectList"))
                    {
                        skillart.tipEffect = new List <SkillEffectUnit>();
                    }
                }
            }
            showBeginCamera = EditorGUILayout.Foldout(showBeginCamera, "beginCameraAction 开始相机特效:");

            //EditorGUILayout.LabelField("beginCameraAction 开始相机特效:");
            if (showBeginCamera)
            {
                if (skillart.beginCameraAction != null)
                {
                    EditorDrawUtility.DrawCameraActionList(skillart.beginCameraAction, beginCameraScrollPos, out beginCameraScrollPos, width, ref beginCameraList);
                }
                else
                {
                    if (GUILayout.Button("Add beginCameraActionList"))
                    {
                        skillart.beginCameraAction = new List <SkillCameraAction>();
                    }
                }
            }
            showMoveCamera = EditorGUILayout.Foldout(showMoveCamera, "moveCameraAction 移动相机特效:");
            if (showMoveCamera)
            {
                //EditorGUILayout.LabelField("moveCameraAction 移动相机特效:");
                if (skillart.moveCameraAction != null)
                {
                    EditorDrawUtility.DrawCameraActionList(skillart.moveCameraAction, movingCameraScrollPos, out movingCameraScrollPos, width, ref movingCameraList);
                }
                else
                {
                    if (GUILayout.Button("Add moveCameraActionList"))
                    {
                        skillart.moveCameraAction = new List <SkillCameraAction>();
                    }
                }
            }
            showHitCamera = EditorGUILayout.Foldout(showHitCamera, "hitCameraAction 命中相机特效:");
            if (showHitCamera)
            {
                // EditorGUILayout.LabelField("hitCameraAction 命中相机特效:");
                if (skillart.hitCameraAction != null)
                {
                    EditorDrawUtility.DrawCameraActionList(skillart.hitCameraAction, hitCameraScrollPos, out hitCameraScrollPos, width, ref hitCameraList);
                }
                else
                {
                    if (GUILayout.Button("Add hitCameraActionList"))
                    {
                        skillart.hitCameraAction = new List <SkillCameraAction>();
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }