示例#1
0
 void OnDestroy()
 {
     _modelAction      = null;
     _selfModelEditor  = null;
     _otherModelEditor = null;
     _result           = null;
     _actClipList      = null;
 }
示例#2
0
 public void RemoveModel(ModelActionConfigEditor model)
 {
     if (!ModelGroupDict[model.GroupType].Remove(model))
     {
         Debug.LogErrorFormat("{0} 无法从分组中移除", model.MenuItemName);
     }
     if (_modelDict.ContainsKey(model.ModelName))
     {
         _modelDict.Remove(model.ModelName);
     }
 }
示例#3
0
 public void AddModel(ModelActionConfigEditor model)
 {
     if (ModelGroupDict.ContainsKey(model.GroupType))
     {
         ModelGroupDict[model.GroupType].Add(model);
     }
     else
     {
         ModelGroupDict.Add(model.GroupType, new List <ModelActionConfigEditor>());
         ModelGroupDict[model.GroupType].Add(model);
     }
     if (!_modelDict.ContainsKey(model.ModelName))
     {
         _modelDict.Add(model.ModelName, model);
     }
 }
示例#4
0
        public static void Init(ModelActionConfigEditor modelEditor, ModelActionEditor modelAction, Action <ModelActionEditor> result = null)
        {
            var window = GetWindow <ActionWindow>(true, "行为配置窗口", true);

            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(400, 250);
            window.minSize  = new Vector2(400, 250);
            window.maxSize  = new Vector2(400, 250);

            window._selfModelEditor            = modelEditor;
            window._nameStyle                  = SirenixGUIStyles.BoldTitleCentered;
            window._nameStyle.fontSize         = 30;
            window._nameStyle.fontStyle        = FontStyle.Bold;
            window._nameStyle.normal.textColor = Color.white;

            window._modelAction = modelAction;
            window._actionName  = modelAction.ActionName;
            window._isFromOther = modelAction.IsFromOther;
            window._clipIndex   = -1;
            window._otherModel  = modelAction.OtherModelName;
            window._result      = result;

            if (modelAction.IsFromOther)
            {
                window._otherModelEditor = HomeConfigPreview.Instance.GetModelEditor(modelAction.OtherModelName);
                window._actClipList      = window._otherModelEditor.GetActionClips();
            }
            else
            {
                window._otherModel  = string.Empty;
                window._actClipList = modelEditor.GetActionClips();
            }

            if (ModelActionEditor.ActionState.New != modelAction.ActState)
            {
                int length = window._actClipList.Length;
                for (int i = 0; i < length; i++)
                {
                    string item = window._actClipList[i];
                    if (item.Equals(modelAction.ActionClip))
                    {
                        window._clipIndex = i;
                        break;
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// 创建角色动作行为配置文本
        /// 每个角色只能有一套配置
        /// </summary>
        /// <returns></returns>
        public void Create(Action <ModelActionConfigEditor> Result)
        {
            ModelActionConfigEditor model = null;
            var models = Csv.CfgManager.Model.Keys;

            SimplePopupCreator.ShowDialog(new List <string>(models), (name) =>
            {
                var config = new ModelActionConfig()
                {
                    ModelName = name,
                    GroupType = GroupType.None,
                };
                string path = string.Format("{0}/{1}.xml", ActionHomeConfig.Instance.ActionConfigPath, name);
                XmlUtil.Serialize(path, config);
                model = new ModelActionConfigEditor(path);
                if (Result != null)
                {
                    Result(model);
                }
            });
        }
示例#6
0
        public void Delete()
        {
            if (EditorUtility.DisplayDialog("删除操作", "确定要删除文件 -> " + ModelName, "确定", "取消"))
            {
                if (File.Exists(_path))
                {
                    File.Delete(_path);
                }

                ModelCfgWindow window = ModelCfgWindow.GetWindow <ModelCfgWindow>();
                OdinMenuItem   item   = window.MenuTree.Selection.FirstOrDefault();
                if (item != null)
                {
                    ModelActionConfigEditor model = item.ObjectInstance as ModelActionConfigEditor;
                    HomeConfigPreview.Instance.RemoveModel(model);
                    item.Parent.ChildMenuItems.Remove(item);
                    item.MenuTree.Selection.Clear();
                    item.Parent.Select();
                    item.MenuTree.UpdateMenuTree();
                    item.MenuTree.DrawMenuTree();
                }
            }
        }
示例#7
0
        void OnGUI()
        {
            if (EditorApplication.isCompiling)
            {
                Debug.Log("[行为窗口]脚本正在编译,所以自动关闭窗口!");
                Close();
                return;
            }

            SirenixEditorGUI.BeginBox();
            {
                SirenixEditorGUI.BeginBoxHeader();
                GUILayout.Label(_selfModelEditor.ModelName, _nameStyle);
                SirenixEditorGUI.EndBoxHeader();
                switch (_modelAction.ActState)
                {
                case ModelActionEditor.ActionState.New:
                    _actionName = EditorGUILayout.TextField("动作行为", _actionName);
                    break;

                case ModelActionEditor.ActionState.Inherit:
                case ModelActionEditor.ActionState.Override:
                    GUILayout.Label("动作行为");
                    GUILayout.Label(_actionName, EditorStyles.textField, GUILayout.Width(EditorGUIUtility.fieldWidth));
                    break;
                }

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("动画来源", GUILayout.Width(145));
                    if (GUILayout.Button("自己", _isFromOther ? SirenixGUIStyles.ButtonLeft : SirenixGUIStyles.ButtonLeftSelected))
                    {
                        _clipIndex   = -1;
                        _isFromOther = false;
                        _otherModel  = string.Empty;
                        _actClipList = _selfModelEditor.GetActionClips();
                    }
                    if (GUILayout.Button("其他", _isFromOther ? SirenixGUIStyles.ButtonRightSelected : SirenixGUIStyles.ButtonRight))
                    {
                        _isFromOther = true;
                        _clipIndex   = -1;
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (_isFromOther)
                {
                    GUIHelper.PushGUIEnabled(!string.IsNullOrEmpty(_otherModel));
                }
                EditorGUILayout.BeginHorizontal();
                {
                    _clipIndex = EditorGUILayout.Popup("动画文件", _clipIndex, _actClipList);
                    if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
                    {
                        _clipIndex = -1;
                    }
                }
                EditorGUILayout.EndHorizontal();
                if (_isFromOther)
                {
                    GUIHelper.PopGUIEnabled();
                }

                if (_isFromOther)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUIHelper.PushColor(_color);
                        GUILayout.Label("其他角色", SirenixGUIStyles.BoldLabel, GUILayout.Width(147));
                        GUILayout.Label(_otherModel, EditorStyles.textField);
                        if (GUILayout.Button("修改", GUILayout.Width(45)))
                        {
                            var list = HomeConfigPreview.Instance.GetAllModelList();
                            list.Remove(_selfModelEditor.ModelName);
                            SimplePopupCreator.ShowDialog(list, (name) =>
                            {
                                _otherModel       = name;
                                _otherModelEditor = HomeConfigPreview.Instance.GetModelEditor(name);
                                _actClipList      = _otherModelEditor.GetActionClips();
                            });
                        }
                        if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
                        {
                            _otherModel = string.Empty;
                        }
                        GUIHelper.PopColor();
                    }
                    EditorGUILayout.EndHorizontal();
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("修改行为", GUILayout.Height(50)))
                    {
                        _modelAction.ActionName  = _actionName;
                        _modelAction.IsFromOther = _isFromOther;
                        bool hasClip = !(_clipIndex < 0 || _actClipList.Length == 0);
                        _modelAction.ActionClip     = hasClip ? _actClipList[_clipIndex] : string.Empty;
                        _modelAction.OtherModelName = _otherModel;

                        bool hasSame = false;
                        if (!_modelAction.IsSkillAction)
                        {
                            foreach (var item in _selfModelEditor.ModelActions)
                            {
                                if (item.ActionName.Equals(_actionName))
                                {
                                    hasSame = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            foreach (var item in _selfModelEditor.SkillActions)
                            {
                                if (item.ActionName.Equals(_actionName))
                                {
                                    hasSame = true;
                                    break;
                                }
                            }
                        }
                        if (!hasSame)
                        {
                            if (_result != null)
                            {
                                _result(_modelAction);
                            }
                            Close();
                        }
                        else
                        {
                            EditorUtility.DisplayDialog("动作配置错误", "动作名重复,请重新配置!!!", "确定");
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndHorizontal();
        }
示例#8
0
 public ModelActionEditor(ModelActionEditor actionEditor)
 {
     _modelEditor   = actionEditor._modelEditor;
     _modelAction   = actionEditor._modelAction;
     _isSkillAction = actionEditor._isSkillAction;
 }
示例#9
0
 public ModelActionEditor(ModelActionConfigEditor modelEditor, ModelAction modelAction, bool isSkill)
 {
     _modelEditor   = modelEditor;
     _modelAction   = modelAction;
     _isSkillAction = isSkill;
 }