protected override void Common1()
        {
            nodeValue.subTreeValue = EditorGUILayout.LongField("SubTreeValue:", nodeValue.subTreeValue);
            string[] nameArr = EnumNames.GetEnumNames <SUB_TREE_TYPE>();
            int      index   = EnumNames.GetEnumIndex <SUB_TREE_TYPE>((SUB_TREE_TYPE)nodeValue.subTreeType);
            int      result  = EditorGUILayout.Popup(new GUIContent("子树类型"), index, nameArr);

            nodeValue.subTreeType   = (int)(EnumNames.GetEnum <SUB_TREE_TYPE>(result));
            nodeValue.subTreeConfig = EditorGUILayout.TextField(new GUIContent("配置文件"), nodeValue.subTreeConfig);
            GUILayout.Space(5);

            if (nodeValue.subTreeType == (int)SUB_TREE_TYPE.CONFIG)
            {
                DataHandler dataHandler = new DataHandler();
                dataHandler.DeleteSubTreeChild(nodeValue.id);

                if (GUILayout.Button("选择子树配置文件"))
                {
                    ConfigFileSelect configFileSelect = new ConfigFileSelect();
                    nodeValue.subTreeConfig = configFileSelect.Select();
                }
            }
            else
            {
                if (GUILayout.Button("将子树存储为配置文件"))
                {
                    ConfigFileSaveSubTree configFileSaveSubTree = new ConfigFileSaveSubTree();
                    configFileSaveSubTree.SaveSubTree(nodeValue.subTreeConfig, nodeValue.id);
                }
            }
        }
Exemplo n.º 2
0
        private void CompositeNode(NodeValue nodeValue)
        {
            if (nodeValue.NodeType == (int)NODE_TYPE.CONDITION ||
                nodeValue.NodeType == (int)NODE_TYPE.ACTION)
            {
                return;
            }

            EditorGUILayout.BeginHorizontal(/*"box"*/);
            {
                string[]      nameArr  = EnumNames.GetEnumNames <NODE_TYPE>();
                List <string> nameList = new List <string>(nameArr);

                NODE_TYPE[] removeTypeArr = new NODE_TYPE[2] {
                    NODE_TYPE.ACTION, NODE_TYPE.CONDITION
                };
                for (int i = nameList.Count - 1; i >= 0; --i)
                {
                    for (int j = 0; j < removeTypeArr.Length; ++j)
                    {
                        NODE_TYPE type  = removeTypeArr[j];
                        int       value = EnumNames.GetEnumIndex <NODE_TYPE>(type);
                        string    name  = EnumNames.GetEnumName <NODE_TYPE>(value);
                        if (name.CompareTo(nameList[i]) == 0)
                        {
                            nameList.RemoveAt(i);
                            break;
                        }
                    }
                }
                nameArr = nameList.ToArray();
                int index = EnumNames.GetEnumIndex <NODE_TYPE>((NODE_TYPE)nodeValue.NodeType);
                if (index > nameArr.Length)
                {
                    index -= 2;//把 条件节点、行为节点,两个节点减掉
                }

                if ((NODE_TYPE)nodeValue.NodeType != NODE_TYPE.SUB_TREE)
                {
                    int result = EditorGUILayout.Popup(new GUIContent("改变节点类型"), index, nameArr);
                    if (result != index)
                    {
                        nodeValue.NodeType = (int)(EnumNames.GetEnum <NODE_TYPE>(result));
                        nodeValue.nodeName = EnumNames.GetEnumName <NODE_TYPE>(result);
                        nodeValue.function = NodeDescript.GetFunction((NODE_TYPE)nodeValue.NodeType);;

                        Debug.LogError(nodeValue.nodeName);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 3
0
        private void SubTreeNode(NodeValue nodeValue)
        {
            nodeValue.subTreeValue = EditorGUILayout.LongField("SubTreeValue:", nodeValue.subTreeValue);
            string[] nameArr = EnumNames.GetEnumNames <SUB_TREE_TYPE>();
            int      index   = EnumNames.GetEnumIndex <SUB_TREE_TYPE>((SUB_TREE_TYPE)nodeValue.subTreeType);
            int      result  = EditorGUILayout.Popup(new GUIContent("子树类型"), index, nameArr);

            nodeValue.subTreeType = (int)(EnumNames.GetEnum <SUB_TREE_TYPE>(result));

            GUILayout.Space(8);
            nodeValue.subTreeConfig = EditorGUILayout.TextField(new GUIContent("配置文件"), nodeValue.subTreeConfig);
            GUILayout.Space(5);

            if (nodeValue.subTreeType == (int)SUB_TREE_TYPE.CONFIG)
            {
                if (null != BehaviorManager.behaviorDeleteSubTreeChild)
                {
                    BehaviorManager.behaviorDeleteSubTreeChild(nodeValue.id);
                }

                if (GUILayout.Button("选择子树配置文件"))
                {
                    if (null != BehaviorManager.behaviorSelectFile)
                    {
                        nodeValue.subTreeConfig = BehaviorManager.behaviorSelectFile();
                    }
                }
            }
            else
            {
                if (GUILayout.Button("将子树存储为配置文件"))
                {
                    if (null != BehaviorManager.behaviorSaveSubTree)
                    {
                        BehaviorManager.behaviorSaveSubTree(nodeValue.subTreeConfig, nodeValue.id);
                    }
                }
            }
        }
        protected override void Common1()
        {
            HashSet <int> childHash = new HashSet <int>();

            if (nodeValue.childNodeList.Count > 3)
            {
                if (null != TreeNodeWindow.window)
                {
                    string msg = string.Format("判断节点 {0} 最多只能有三个节点", nodeValue.id);
                    TreeNodeWindow.window.ShowNotification(msg);
                }

                while (nodeValue.childNodeList.Count > 3)
                {
                    nodeValue.childNodeList.RemoveAt(nodeValue.childNodeList.Count - 1);
                }

                while (nodeValue.ifJudgeDataList.Count > 3)
                {
                    nodeValue.ifJudgeDataList.RemoveAt(nodeValue.ifJudgeDataList.Count - 1);
                }
            }

            EditorGUILayout.BeginVertical("box");
            {
                for (int i = 0; i < nodeValue.childNodeList.Count; ++i)
                {
                    int childId = nodeValue.childNodeList[i];
                    childHash.Add(childId);
                    IfJudgeData judgeData = nodeValue.ifJudgeDataList.Find((a) => { return(a.nodeId == childId); });
                    if (null == judgeData)
                    {
                        judgeData        = new IfJudgeData();
                        judgeData.nodeId = childId;
                        nodeValue.ifJudgeDataList.Add(judgeData);
                    }
                    judgeData.ifJudegType = ((i == 0) ? (int)NodeIfJudgeEnum.IF : (int)NodeIfJudgeEnum.ACTION);

                    EditorGUILayout.BeginVertical("box");
                    {
                        GUI.enabled = false;
                        EditorGUILayout.IntField("nodeId:", judgeData.nodeId);
                        {
                            string[] nameArr = EnumNames.GetEnumNames <NodeIfJudgeEnum>();
                            int      index   = EnumNames.GetEnumIndex <NodeIfJudgeEnum>((NodeIfJudgeEnum)judgeData.ifJudegType);
                            int      result  = EditorGUILayout.Popup(new GUIContent("节点类型"), index, nameArr);
                            judgeData.ifJudegType = (int)(EnumNames.GetEnum <NodeIfJudgeEnum>(result));
                        }
                        GUI.enabled = true;

                        if (judgeData.ifJudegType == (int)NodeIfJudgeEnum.ACTION)
                        {
                            string[] nameArr  = new string[] { "Fail", "Success" };
                            int      oldValue = judgeData.ifResult;
                            int      result   = EditorGUILayout.Popup(new GUIContent("执行条件"), judgeData.ifResult, nameArr);
                            if (oldValue != result)
                            {
                                JudgeNodeChangeChildCondition(nodeValue, judgeData.nodeId, (ResultType)result);
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();
                }

                EditorGUILayout.BeginVertical("box");
                {
                    EditorGUILayout.LabelField("没有 if判断节点 返回结果对应类型的 执行节点");
                    string[] nameArr = new string[] { "Fail", "Success", "Running" };
                    nodeValue.defaultResult = EditorGUILayout.Popup(new GUIContent("默认返回结果"), nodeValue.defaultResult, nameArr);
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();

            for (int i = nodeValue.ifJudgeDataList.Count - 1; i >= 0; --i)
            {
                IfJudgeData data = nodeValue.ifJudgeDataList[i];
                if (!childHash.Contains(data.nodeId))
                {
                    nodeValue.ifJudgeDataList.RemoveAt(i);
                }
            }

            nodeValue.ifJudgeDataList.Sort((a, b) =>
            {
                return(a.ifJudegType - b.ifJudegType);
            });
        }
Exemplo n.º 5
0
        public static NodeParameter Draw(NodeParameter behaviorParameter, DrawParameterType drawParameterType, Action DelCallBack)
        {
            if (null == behaviorParameter)
            {
                return(behaviorParameter);
            }

            EditorGUILayout.BeginHorizontal();
            {
                string[]      parameterNameArr      = EnumNames.GetEnumNames <ParameterType>();
                int           index                 = EnumNames.GetEnumIndex <ParameterType>((ParameterType)(behaviorParameter.parameterType));
                ParameterType behaviorParameterType = EnumNames.GetEnum <ParameterType>(index);

                GUI.enabled = false;
                if (drawParameterType == DrawParameterType.NODE_PARAMETER)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        behaviorParameter.index = EditorGUILayout.IntField(behaviorParameter.index, GUILayout.Width(30));
                    }
                    EditorGUILayout.EndHorizontal();
                }

                bool enableChangeType = (drawParameterType == DrawParameterType.BEHAVIOR_PARAMETER_ADD);
                GUI.enabled = enableChangeType && !BehaviorDataController.Instance.CurrentOpenConfigSubTree();
                {
                    index = EditorGUILayout.Popup(index, parameterNameArr);
                    behaviorParameter.parameterType = (int)EnumNames.GetEnum <ParameterType>(index);
                    GUILayout.Space(5);
                }
                GUI.enabled = true;

                if (drawParameterType == DrawParameterType.NODE_PARAMETER)
                {
                    GUI.enabled = false;
                    EditorGUILayout.BeginHorizontal();
                    {
                        behaviorParameter.parameterName = EditorGUILayout.TextField(behaviorParameter.parameterName);
                    }
                    EditorGUILayout.EndHorizontal();
                    GUI.enabled = true;
                }

                if (drawParameterType == DrawParameterType.NODE_PARAMETER || drawParameterType == DrawParameterType.BEHAVIOR_PARAMETER)
                {
                    GUI.enabled = !BehaviorDataController.Instance.CurrentOpenConfigSubTree();
                    if (GUILayout.Button("Del"))
                    {
                        if (null != DelCallBack)
                        {
                            DelCallBack();
                        }
                    }
                    GUI.enabled = true;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                if (drawParameterType == DrawParameterType.NODE_PARAMETER)
                {
                    List <NodeParameter> parameterList = BehaviorDataController.Instance.BehaviorTreeData.parameterList;
                    string[]             parameterArr  = new string[parameterList.Count];
                    int index = -1;
                    for (int i = 0; i < parameterList.Count; ++i)
                    {
                        NodeParameter p = parameterList[i];
                        parameterArr[i] = p.CNName;
                        if (behaviorParameter.parameterName.CompareTo(p.parameterName) == 0)
                        {
                            index = i;
                        }
                    }

                    GUI.enabled = !BehaviorDataController.Instance.CurrentOpenConfigSubTree();
                    int result = EditorGUILayout.Popup(index, parameterArr, GUILayout.ExpandWidth(true));
                    GUI.enabled = true;
                    if (result != index)
                    {
                        behaviorParameter.parameterName = parameterList[result].parameterName;
                    }
                }
                else if (drawParameterType == DrawParameterType.BEHAVIOR_PARAMETER ||
                         drawParameterType == DrawParameterType.RUNTIME_PARAMETER)
                {
                    GUI.enabled = false;
                    behaviorParameter.parameterName = EditorGUILayout.TextField(behaviorParameter.parameterName);
                    GUI.enabled = true;
                    string cnName = EditorGUILayout.TextField(behaviorParameter.CNName);
                    if (cnName.CompareTo(behaviorParameter.CNName) != 0)
                    {
                        TreeNodeWindow.window.ShowNotification("此处字段名只支持查看,不能修改");
                    }
                }
                else if (drawParameterType == DrawParameterType.BEHAVIOR_PARAMETER_ADD)
                {
                    EditorGUILayout.BeginVertical();
                    {
                        string oldName = behaviorParameter.parameterName;
                        behaviorParameter.parameterName = EditorGUILayout.TextField("英文:", behaviorParameter.parameterName);
                        if (oldName.CompareTo(behaviorParameter.parameterName) != 0)
                        {
                            bool isNumOrAlp = IsNumOrAlp(behaviorParameter.parameterName);
                            if (!isNumOrAlp)
                            {
                                string msg = string.Format("参数名只能包含:数字、字母、下划线,且数字不能放在第一个字符位置");
                                TreeNodeWindow.window.ShowNotification(msg);
                                behaviorParameter.parameterName = oldName;
                            }
                        }

                        behaviorParameter.CNName = EditorGUILayout.TextField("中文", behaviorParameter.CNName);
                    }
                    EditorGUILayout.EndVertical();
                }

                ParameterCompare[] compareEnumArr = new ParameterCompare[] { };
                if (behaviorParameter.parameterType == (int)ParameterType.Int)
                {
                    compareEnumArr = new ParameterCompare[] { ParameterCompare.GREATER, ParameterCompare.GREATER_EQUALS, ParameterCompare.LESS_EQUAL, ParameterCompare.LESS, ParameterCompare.EQUALS, ParameterCompare.NOT_EQUAL };
                }
                if (behaviorParameter.parameterType == (int)ParameterType.Long)
                {
                    compareEnumArr = new ParameterCompare[] { ParameterCompare.GREATER, ParameterCompare.GREATER_EQUALS, ParameterCompare.LESS_EQUAL, ParameterCompare.LESS, ParameterCompare.EQUALS, ParameterCompare.NOT_EQUAL };
                }
                if (behaviorParameter.parameterType == (int)ParameterType.Float)
                {
                    compareEnumArr = new ParameterCompare[] { ParameterCompare.GREATER, ParameterCompare.LESS };
                }
                if (behaviorParameter.parameterType == (int)ParameterType.Bool)
                {
                    compareEnumArr = new ParameterCompare[] { ParameterCompare.EQUALS, ParameterCompare.NOT_EQUAL };
                }

                if (behaviorParameter.parameterType == (int)ParameterType.String)
                {
                    compareEnumArr = new ParameterCompare[] { ParameterCompare.EQUALS, ParameterCompare.NOT_EQUAL };
                }

                string[] compareArr = new string[compareEnumArr.Length];
                int      compare    = behaviorParameter.compare;
                bool     found      = false;
                for (int i = 0; i < compareEnumArr.Length; ++i)
                {
                    string name = System.Enum.GetName(typeof(ParameterCompare), compareEnumArr[i]);
                    compareArr[i] = name;
                    if ((ParameterCompare)behaviorParameter.compare == compareEnumArr[i])
                    {
                        compare = i;
                        found   = true;
                    }
                }

                if (!found)
                {
                    compare = 0;
                }

                GUI.enabled = (drawParameterType != DrawParameterType.BEHAVIOR_PARAMETER) && (drawParameterType != DrawParameterType.RUNTIME_PARAMETER) && !BehaviorDataController.Instance.CurrentOpenConfigSubTree();;
                bool value    = (drawParameterType != DrawParameterType.BEHAVIOR_PARAMETER) && (drawParameterType != DrawParameterType.RUNTIME_PARAMETER) && (drawParameterType != DrawParameterType.BEHAVIOR_PARAMETER_ADD);
                bool boolType = (behaviorParameter.parameterType == (int)ParameterType.Bool);
                if (value && !boolType)
                {
                    compare = EditorGUILayout.Popup(compare, compareArr, GUILayout.Width(65));
                    behaviorParameter.compare = (int)(compareEnumArr[compare]);
                }
                GUI.enabled = true;

                if (boolType)
                {
                    behaviorParameter.compare = (int)ParameterCompare.EQUALS;
                }

                GUI.enabled = true && !BehaviorDataController.Instance.CurrentOpenConfigSubTree();
                {
                    if (behaviorParameter.parameterType == (int)ParameterType.Int)
                    {
                        behaviorParameter.intValue = EditorGUILayout.IntField(behaviorParameter.intValue, GUILayout.Width(60));
                    }

                    if (behaviorParameter.parameterType == (int)ParameterType.Long)
                    {
                        behaviorParameter.longValue = EditorGUILayout.LongField(behaviorParameter.longValue, GUILayout.Width(60));
                    }

                    if (behaviorParameter.parameterType == (int)ParameterType.Float)
                    {
                        behaviorParameter.floatValue = EditorGUILayout.FloatField(behaviorParameter.floatValue, GUILayout.Width(60));
                    }

                    if (behaviorParameter.parameterType == (int)ParameterType.Bool)
                    {
                        behaviorParameter.boolValue = EditorGUILayout.Toggle(behaviorParameter.boolValue, GUILayout.Width(60));
                    }

                    if (behaviorParameter.parameterType == (int)ParameterType.String)
                    {
                        behaviorParameter.stringValue = EditorGUILayout.TextField(behaviorParameter.stringValue, GUILayout.Width(60));
                    }
                }
                GUI.enabled = true;
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5);

            return(behaviorParameter);
        }
Exemplo n.º 6
0
        public static BehaviorParameter Draw(BehaviorParameter behaviorParameter, DrawParameterType drawParameterType, Action DelCallBack)
        {
            if (null == behaviorParameter)
            {
                return(behaviorParameter);
            }

            {
                string[] parameterNameArr = EnumNames.GetEnumNames <BehaviorParameterType>();
                int      index            = EnumNames.GetEnumIndex <BehaviorParameterType>((BehaviorParameterType)(behaviorParameter.parameterType));
                BehaviorParameterType behaviorParameterType = EnumNames.GetEnum <BehaviorParameterType>(index);

                bool enableChangeType = (drawParameterType == DrawParameterType.GLOBAL_PARAMETER_ADD);
                GUI.enabled = enableChangeType;
                {
                    index = EditorGUILayout.Popup(index, parameterNameArr);
                    behaviorParameter.parameterType = (int)EnumNames.GetEnum <BehaviorParameterType>(index);
                    GUILayout.Space(5);
                }
                GUI.enabled = true;
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (drawParameterType == DrawParameterType.NODE_PARAMETER)
                {
                    List <BehaviorParameter> parameterList = BehaviorManager.Instance.GlobalParameter.parameterList;
                    string[] parameterArr = new string[parameterList.Count];
                    int      index        = -1;
                    for (int i = 0; i < parameterList.Count; ++i)
                    {
                        BehaviorParameter p = parameterList[i];
                        parameterArr[i] = p.parameterName;
                        if (behaviorParameter.parameterName.CompareTo(p.parameterName) == 0)
                        {
                            index = i;
                        }
                    }

                    int result = EditorGUILayout.Popup(index, parameterArr, GUILayout.ExpandWidth(true));
                    if (result != index)
                    {
                        behaviorParameter.parameterName = parameterArr[result];
                    }
                }
                else if (drawParameterType == DrawParameterType.GLOBAL_PARAMETER ||
                         (drawParameterType == DrawParameterType.GLOBAL_PARAMETER_ADD) ||
                         drawParameterType == DrawParameterType.RUNTIME_PARAMETER)
                {
                    GUI.enabled = (drawParameterType == DrawParameterType.GLOBAL_PARAMETER_ADD);
                    behaviorParameter.parameterName = EditorGUILayout.TextField(behaviorParameter.parameterName);
                    GUI.enabled = true;
                }

                BehaviorCompare[] compareEnumArr = new BehaviorCompare[] { };
                if (behaviorParameter.parameterType == (int)BehaviorParameterType.Int)
                {
                    compareEnumArr = new BehaviorCompare[] { BehaviorCompare.GREATER, BehaviorCompare.GREATER_EQUALS, BehaviorCompare.LESS_EQUAL, BehaviorCompare.LESS, BehaviorCompare.EQUALS, BehaviorCompare.NOT_EQUAL };
                }
                if (behaviorParameter.parameterType == (int)BehaviorParameterType.Float)
                {
                    compareEnumArr = new BehaviorCompare[] { BehaviorCompare.GREATER, BehaviorCompare.LESS };
                }
                if (behaviorParameter.parameterType == (int)BehaviorParameterType.Bool)
                {
                    compareEnumArr = new BehaviorCompare[] { BehaviorCompare.EQUALS, BehaviorCompare.NOT_EQUAL };
                }
                string[] compareArr = new string[compareEnumArr.Length];
                int      compare    = behaviorParameter.compare;
                bool     found      = false;
                for (int i = 0; i < compareEnumArr.Length; ++i)
                {
                    string name = System.Enum.GetName(typeof(BehaviorCompare), compareEnumArr[i]);
                    compareArr[i] = name;
                    if ((BehaviorCompare)behaviorParameter.compare == compareEnumArr[i])
                    {
                        compare = i;
                        found   = true;
                    }
                }

                if (!found)
                {
                    compare = 0;
                }

                GUI.enabled = (drawParameterType != DrawParameterType.GLOBAL_PARAMETER) && (drawParameterType != DrawParameterType.RUNTIME_PARAMETER);
                {
                    compare = EditorGUILayout.Popup(compare, compareArr, GUILayout.Width(65));
                    behaviorParameter.compare = (int)(compareEnumArr[compare]);
                }
                GUI.enabled = true;
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal();
            {
                GUI.enabled = (drawParameterType != DrawParameterType.GLOBAL_PARAMETER);
                {
                    if (behaviorParameter.parameterType == (int)BehaviorParameterType.Int)
                    {
                        behaviorParameter.intValue = EditorGUILayout.IntField("DefaultIntValue", behaviorParameter.intValue);
                    }

                    if (behaviorParameter.parameterType == (int)BehaviorParameterType.Float)
                    {
                        behaviorParameter.floatValue = EditorGUILayout.FloatField("DefaultFloatValue", behaviorParameter.floatValue);
                    }

                    if (behaviorParameter.parameterType == (int)BehaviorParameterType.Bool)
                    {
                        behaviorParameter.boolValue = EditorGUILayout.Toggle("DefaultBoolValue", behaviorParameter.boolValue);
                    }
                }
                GUI.enabled = true;

                if (drawParameterType == DrawParameterType.NODE_PARAMETER || drawParameterType == DrawParameterType.GLOBAL_PARAMETER)
                {
                    if (GUILayout.Button("Del"))
                    {
                        if (null != DelCallBack)
                        {
                            DelCallBack();
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            return(behaviorParameter);
        }
Exemplo n.º 7
0
        public static SkillHsmConfigHSMParameter Draw(SkillHsmConfigHSMParameter hSMParameter, HSMDrawParameterType drawParameterType, Action DelCallBack)
        {
            if (null == hSMParameter)
            {
                return(hSMParameter);
            }

            EditorGUILayout.BeginHorizontal();
            {
                string[]         parameterNameArr = EnumNames.GetEnumNames <HSMParameterType>();
                int              index            = EnumNames.GetEnumIndex <HSMParameterType>((HSMParameterType)(hSMParameter.ParameterType));
                HSMParameterType HSMParameterType = EnumNames.GetEnum <HSMParameterType>(index);

                bool enableChangeType = (drawParameterType == HSMDrawParameterType.HSM_PARAMETER_ADD);
                GUI.enabled = enableChangeType;
                {
                    GUI.enabled = false;
                    if (drawParameterType == HSMDrawParameterType.NODE_PARAMETER)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            hSMParameter.Index = EditorGUILayout.IntField(hSMParameter.Index, GUILayout.Width(30));
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    GUI.enabled = enableChangeType;

                    index = EditorGUILayout.Popup(index, parameterNameArr, GUILayout.ExpandWidth(true));
                    hSMParameter.ParameterType = (int)EnumNames.GetEnum <HSMParameterType>(index);
                    GUILayout.Space(5);
                }
                GUI.enabled = true;

                if (drawParameterType == HSMDrawParameterType.NODE_PARAMETER || drawParameterType == HSMDrawParameterType.HSM_PARAMETER)
                {
                    if (GUILayout.Button("删除", GUILayout.Width(45)))
                    {
                        if (null != DelCallBack)
                        {
                            DelCallBack();
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                if (drawParameterType == HSMDrawParameterType.NODE_PARAMETER)
                {
                    List <SkillHsmConfigHSMParameter> parameterList = HSMManager.Instance.HSMTreeData.ParameterList;
                    string[] parameterArr = new string[parameterList.Count];
                    int      index        = -1;
                    for (int i = 0; i < parameterList.Count; ++i)
                    {
                        SkillHsmConfigHSMParameter p = parameterList[i];
                        parameterArr[i] = p.CNName; //p.ParameterName;
                        if (hSMParameter.ParameterName.CompareTo(p.ParameterName) == 0)
                        {
                            index = i;
                        }
                    }

                    int result = EditorGUILayout.Popup(index, parameterArr, GUILayout.ExpandWidth(true));
                    if (result != index)
                    {
                        hSMParameter.ParameterName = parameterList[result].ParameterName; //parameterArr[result];
                    }
                }
                else if (drawParameterType == HSMDrawParameterType.HSM_PARAMETER ||
                         drawParameterType == HSMDrawParameterType.RUNTIME_PARAMETER)
                {
                    GUI.enabled = (drawParameterType == HSMDrawParameterType.HSM_PARAMETER_ADD);
                    hSMParameter.ParameterName = EditorGUILayout.TextField(hSMParameter.ParameterName);
                    hSMParameter.CNName        = EditorGUILayout.TextField(hSMParameter.CNName);
                    GUI.enabled = true;
                }
                else if (drawParameterType == HSMDrawParameterType.HSM_PARAMETER_ADD)
                {
                    EditorGUILayout.BeginVertical();
                    {
                        string oldName = hSMParameter.ParameterName;
                        hSMParameter.ParameterName = EditorGUILayout.TextField("英文:", hSMParameter.ParameterName);
                        if (oldName.CompareTo(hSMParameter.ParameterName) != 0)
                        {
                            bool isNumOrAlp = IsNumOrAlp(hSMParameter.ParameterName);
                            if (!isNumOrAlp)
                            {
                                string msg = string.Format("参数名只能包含:数字、字母、下划线,且数字不能放在第一个字符位置");
                                HSMNodeWindow.window.ShowNotification(msg);
                                hSMParameter.ParameterName = oldName;
                            }
                        }

                        hSMParameter.CNName = EditorGUILayout.TextField("中文", hSMParameter.CNName);
                    }
                    EditorGUILayout.EndVertical();
                }
                HSMCompare[] compareEnumArr = new HSMCompare[] { };
                if (hSMParameter.ParameterType == (int)HSMParameterType.Int)
                {
                    compareEnumArr = new HSMCompare[] { HSMCompare.GREATER, HSMCompare.GREATER_EQUALS, HSMCompare.LESS_EQUAL, HSMCompare.LESS, HSMCompare.EQUALS, HSMCompare.NOT_EQUAL };
                }
                if (hSMParameter.ParameterType == (int)HSMParameterType.Float)
                {
                    compareEnumArr = new HSMCompare[] { HSMCompare.GREATER, HSMCompare.LESS };
                }
                if (hSMParameter.ParameterType == (int)HSMParameterType.Bool)
                {
                    compareEnumArr = new HSMCompare[] { HSMCompare.EQUALS, HSMCompare.NOT_EQUAL };
                }
                string[] compareArr = new string[compareEnumArr.Length];
                int      compare    = hSMParameter.Compare;
                bool     found      = false;
                for (int i = 0; i < compareEnumArr.Length; ++i)
                {
                    int    index    = EnumNames.GetEnumIndex <HSMCompare>(compareEnumArr[i]);
                    string typeName = EnumNames.GetEnumName <HSMCompare>(index);
                    compareArr[i] = typeName;
                    if ((HSMCompare)hSMParameter.Compare == compareEnumArr[i])
                    {
                        compare = i;
                        found   = true;
                    }
                }

                if (!found)
                {
                    compare = 0;
                }

                bool value    = (drawParameterType != HSMDrawParameterType.HSM_PARAMETER) && (drawParameterType != HSMDrawParameterType.RUNTIME_PARAMETER) && (drawParameterType != HSMDrawParameterType.HSM_PARAMETER_ADD);
                bool boolType = (hSMParameter.ParameterType == (int)HSMParameterType.Bool);
                if (boolType)
                {
                    hSMParameter.Compare = (int)HSMCompare.EQUALS;
                }
                else if (value)
                {
                    compare = EditorGUILayout.Popup(compare, compareArr, GUILayout.Width(65));
                    hSMParameter.Compare = (int)(compareEnumArr[compare]);
                }

                {
                    if (hSMParameter.ParameterType == (int)HSMParameterType.Int)
                    {
                        hSMParameter.IntValue = EditorGUILayout.IntField(hSMParameter.IntValue, GUILayout.Width(50));
                    }

                    if (hSMParameter.ParameterType == (int)HSMParameterType.Float)
                    {
                        hSMParameter.FloatValue = EditorGUILayout.FloatField(hSMParameter.FloatValue, GUILayout.Width(50));
                    }

                    if (hSMParameter.ParameterType == (int)HSMParameterType.Bool)
                    {
                        hSMParameter.BoolValue = EditorGUILayout.Toggle(hSMParameter.BoolValue, GUILayout.Width(50));
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            return(hSMParameter);
        }