Пример #1
0
        private void ModifyModelName()
        {
            var models = new List <string>(CfgManager.Model.Keys);

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

                ActorCfgWindow window = ActorCfgWindow.GetWindow <ActorCfgWindow>();
                OdinMenuItem item     = window.MenuTree.Selection.FirstOrDefault();
                item.Name             = name;
                item.SearchString     = name;
            });
        }
Пример #2
0
        /// <summary>
        /// 创建角色动作行为配置文本
        /// 每个角色只能有一套配置
        /// </summary>
        /// <returns></returns>
        private void Create()
        {
            ActorConfigEditor model = null;
            var models = CfgManager.Model.Keys;

            SimplePopupCreator.ShowDialog(new List <string>(models), (name) =>
            {
                var config = new ActorConfig()
                {
                    ModelName = name
                };
                string path = string.Format("{0}/{1}.xml", ActionHomeConfig.Instance.ActionConfigPath, name);
                model       = new ActorConfigEditor(path, config);
                model.Save();
            });
        }
Пример #3
0
 void OnGUI_Func()
 {
     EditorGUILayout.BeginHorizontal();
     GUIHelper.PushGUIPositionOffset(UnityEngine.Vector2.up * -2);
     if (GUILayout.Button("设置受击对象", GUILayout.Width(150)))
     {
         SimplePopupCreator.ShowDialog(new List <string>(CfgManager.Model.Keys), (name) =>
         {
             _targetDisplayName      = name;
             ActorConfigEditor actor = GetActorEditor(name);
             LoadTarget(actor);
         });
     }
     GUIHelper.PopGUIPositionOffset();
     EditorGUILayout.LabelField(_targetDisplayName, EditorStyles.textArea);
     EditorGUILayout.EndHorizontal();
 }
Пример #4
0
        private void ModifyBaseName()
        {
            List <string> models = HomeConfig.Instance.GetAllActorList();
            string        none   = "-----None-----";

            models.Insert(0, none);
            models.Remove(ModelName);
            SimplePopupCreator.ShowDialog(new List <string>(models), (name) =>
            {
                if (name.Equals(none))
                {
                    name = "";
                }
                string old = _actorCfg.BaseModelName;
                _actorCfg.BaseModelName = name;
                bool oldEmpty           = string.IsNullOrEmpty(old);
                bool newEmpty           = string.IsNullOrEmpty(name);
                if (!oldEmpty)
                {
                    var oldBase = HomeConfig.Instance.GetActorEditor(old);
                    if (!newEmpty && !old.Equals(name))
                    {//--修改继承
                        oldBase.RemoveChildActor(this);
                        var newBase = HomeConfig.Instance.GetActorEditor(name);
                        newBase.AddChildActor(this);
                    }
                    else if (newEmpty)
                    { //--移除继承
                        oldBase.RemoveChildActor(this);
                    }
                }
                else if (!newEmpty)
                {
                    //--添加继承
                    var newBase = HomeConfig.Instance.GetActorEditor(name);
                    newBase.AddChildActor(this);
                }
            });
        }
Пример #5
0
        protected override void OnGUI()
        {
            base.OnGUI();
            if (EditorApplication.isCompiling)
            {
                Debug.Log("[行为窗口]脚本正在编译,所以自动关闭窗口!");
                Close();
                return;
            }

            SirenixEditorGUI.BeginBox();
            {
                SirenixEditorGUI.BeginBoxHeader();
                GUILayout.Label(_selfActorEditor.ModelName, _nameStyle);
                SirenixEditorGUI.EndBoxHeader();
                bool isNew = _modelAction.ActState == ModelActionEditor.ActionState.New;
                if (!isNew)
                {
                    GUIHelper.PushGUIEnabled(false);
                }
                _actionName = EditorGUILayout.TextField("动作行为", _actionName);
                if (!isNew)
                {
                    GUIHelper.PushGUIEnabled(true);
                }


                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("其他角色", SirenixGUIStyles.BoldLabel, GUILayout.Width(142));
                    if (GUILayout.Button(_otherModelName, EditorStyles.textField))
                    {
                        var list = HomeConfig.Instance.GetAllActorList();
                        list.Remove(_selfActorEditor.ModelName);
                        SimplePopupCreator.ShowDialog(list, (name) => LoadOtherAction(name));
                    }
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
                    {
                        LoadSelfAction();
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("动画文件", SirenixGUIStyles.BoldLabel, GUILayout.Width(142));
                    if (GUILayout.Button(_clipName, SirenixGUIStyles.Popup))
                    {
                        SimplePopupCreator.ShowDialog(_actClipList, (name) => _clipName = name);
                    }
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
                    {
                        _clipName = string.Empty;
                    }
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.FlexibleSpace();
                EditorGUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("修改行为", GUILayout.Height(50)))
                    {
                        if (_isAddAction)
                        {
                            bool hasSame = false;
                            if (!_modelAction.IsSkillAction)
                            {
                                hasSame = _selfActorEditor.GeneralActions.Exists(a => a.ActionName.Equals(_actionName));
                            }
                            else
                            {
                                hasSame = _selfActorEditor.SkillActions.Exists(a => a.ActionName.Equals(_actionName));
                            }

                            if (!hasSame)
                            {
                                _modelAction.ActionName     = _actionName;
                                _modelAction.ActionClip     = _clipName;
                                _modelAction.OtherModelName = _otherModelName;
                                _selfActorEditor.SetChildAction(_modelAction);
                                if (_result != null)
                                {
                                    _result(_modelAction);
                                }
                                Close();
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("动作配置错误", "动作名重复,请重新配置!!!", "确定");
                            }
                        }
                        else
                        {
                            _modelAction.ActionName     = _actionName;
                            _modelAction.ActionClip     = _clipName;
                            _modelAction.OtherModelName = _otherModelName;
                            if (_result != null)
                            {
                                _result(_modelAction);
                            }
                            Close();
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndHorizontal();
        }