예제 #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;

                ActorEditorWindow window = ActorEditorWindow.GetWindow <ActorEditorWindow>();
                OdinMenuItem item        = window.MenuTree.Selection.FirstOrDefault();
                item.Name         = name;
                item.SearchString = name;
            });
        }
예제 #2
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;
             ActorEditor actor  = GetActorEditor(name);
         });
     }
     GUIHelper.PopGUIPositionOffset();
     EditorGUILayout.LabelField(_targetDisplayName, EditorStyles.textArea);
     EditorGUILayout.EndHorizontal();
 }
예제 #3
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);
                }
            });
        }
예제 #4
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 = _action.ActState == ActionEditor.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 (!_action.IsSkillAction)
                            {
                                hasSame = _selfActorEditor.GeneralActions.Exists(a => a.ActionName.Equals(_actionName));
                            }
                            else
                            {
                                hasSame = _selfActorEditor.SkillActions.Exists(a => a.ActionName.Equals(_actionName));
                            }

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