Ejemplo n.º 1
0
        private void ModifyBaseName()
        {
            List <string> models = HomeConfigPreview.Instance.GetAllModelList();

            models.Remove(ModelName);
            SimplePopupCreator.ShowDialog(new List <string>(models), (name) =>
            {
                _modelActionCfg.BaseModelName = name;
                AddBaseModelAction(name);
            });
        }
Ejemplo n.º 2
0
        private void ModifyModelName()
        {
            var models = new List <string>(Csv.CfgManager.Model.Keys);

            models.Remove(ModelName);
            SimplePopupCreator.ShowDialog(new List <string>(models), (name) =>
            {
                _modelActionCfg.ModelName = name;

                ModelCfgWindow window = ModelCfgWindow.GetWindow <ModelCfgWindow>();
                OdinMenuItem item     = window.MenuTree.Selection.FirstOrDefault();
                item.Name             = name;
                item.SearchString     = name;
            });
        }
Ejemplo n.º 3
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);
                }
            });
        }
Ejemplo n.º 4
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();
        }