Esempio n. 1
0
        private void DrawNodeWindow(int id)
        {
            //前提
            if (Json.Premise == null)
            {
                EDTypeField.CreateLableField("无节点前提:", "", mRect.width, 20);
            }
            else
            {
                Type premiseType = LCReflect.GetType(Json.Premise.TypeFullName);
                if (premiseType == null)
                {
                    Json.Premise = null;
                }
                else
                {
                    EDTypeField.CreateLableField("节点前提:" + Json.Premise.Name + "...", "", mRect.width, 20);
                }
            }

            //信息
            EDTypeField.CreateLableField("节点类型:" + Json.Type.ToString(), "", mRect.width, 20);
            EDTypeField.CreateLableField("节点ID:" + MId, "", mRect.width, 20);
            DrawEditorNodeKeyValue();
        }
Esempio n. 2
0
        private void DrawEditorNodeKeyValue()
        {
            EDLayout.CreateScrollView(ref valuePos, "", mRect.width, mRect.height, ((width, height) =>
            {
                //可编辑键值
                for (int j = 0; j < Json.KeyValues.Count; j++)
                {
                    NodeKeyValue keyValue = Json.KeyValues[j];

                    object value = LCConvert.StrChangeToObject(keyValue.Value, keyValue.TypeFullName);
                    Type ty = LCReflect.GetType(keyValue.TypeFullName);
                    EDTypeField.CreateTypeField(keyValue.KeyName + "= ", ref value, ty, width - 10, 20);

                    keyValue.Value = value.ToString();
                }
            }));
        }
Esempio n. 3
0
        private void GetEditorNodeKeyValue()
        {
            Type nodeType = LCReflect.GetType(Json.TypeFullName);

            FieldInfo[] fields = LCReflect.GetTypeFieldInfos(nodeType);

            for (int i = 0; i < fields.Length; i++)
            {
                FieldInfo          info = fields[i];
                NodeValueAttribute nodeValueAttribute = LCReflect.GetFieldAttr <NodeValueAttribute>(info);
                if (nodeValueAttribute != null)
                {
                    if (nodeValueAttribute.ViewEditor)
                    {
                        object defauleValue = LCReflect.GeTypeDefaultFieldValue(Json.TypeFullName, info.Name);
                        UpdateNodeKeyValue(info, defauleValue);
                    }
                }
            }
        }
Esempio n. 4
0
        //组件编辑界面
        private void ShowSelComWindow(float width, float height)
        {
            List <EntityComValueJson> values = UpdateSelComEditorValues();

            EDLayout.CreateScrollView(ref ComValuePos, "Box", width, height, () =>
            {
                for (int i = 0; i < values.Count; i++)
                {
                    EntityComValueJson comView = values[i];
                    Type resType = null;
                    resType      = LCReflect.GetType(comView.Type);
                    if (resType == null)
                    {
                        resType = LCReflect.GetType(comView.Type);
                    }
                    object value = LCConvert.StrChangeToObject(comView.Value, resType.FullName);
                    EDTypeField.CreateTypeField(comView.Name + "= ", ref value, resType, width, 40);
                    SetSelComJson(comView.Name, value.ToString());
                }
            });
        }
Esempio n. 5
0
        //实体编辑界面
        private void ShowSelEntityWindow(float width)
        {
            //基础配置只读
            EDTypeField.CreateLableField("实体名:", SelEntity.EntityName, width, 20);

            object tipobj = SelEntity.TipStr;

            EDTypeField.CreateTypeField("描述信息:", ref tipobj, typeof(string), width, 20);
            SelEntity.TipStr = tipobj.ToString();

            //决策分组
            SelEntity.Group = (EntityDecGroup)EditorGUILayout.EnumPopup("实体决策分组", SelEntity.Group);
            EditorGUILayout.Space();

            //预制体路径
            EditorGUILayout.LabelField("选择预制体:");
            GameObject prefab = null;

            prefab = EditorGUILayout.ObjectField(prefab, typeof(GameObject), false) as GameObject;
            if (prefab != null)
            {
                SelEntity.PrefabPath = AssetDatabase.GetAssetPath(prefab);
            }
            EditorGUILayout.LabelField("预制体路径:");
            EditorGUILayout.LabelField(SelEntity.PrefabPath, "", "box");
            EditorGUILayout.Space();

            //组件列表
            EditorGUILayout.LabelField("组件列表:");
            EDLayout.CreateScrollView(ref ComListPos, "box", width, 150, () => {
                for (int i = 0; i < SelEntity.Coms.Count; i++)
                {
                    //按钮名
                    string btnName = SelEntity.Coms[i].ComName;
                    Type comType   = LCReflect.GetType(SelEntity.Coms[i].ComName);
                    if (comType != null)
                    {
                        ComAttribute comAttribute = LCReflect.GetTypeAttr <ComAttribute>(comType);
                        if (comAttribute != null)
                        {
                            btnName = comAttribute.ViewName;
                        }
                    }
                    else
                    {
                        SelEntity.Coms.RemoveAt(i);
                        continue;
                    }

                    EDButton.CreateBtn(btnName, width * 0.8f, 20, () =>
                    {
                        int comIndex = i;
                        EDPopMenu.CreatePopMenu(new List <string>()
                        {
                            "编辑组件", "删除组件"
                        }, (int index) =>
                        {
                            if (index == 0)
                            {
                                SelCom = LCReflect.GetType(SelEntity.Coms[comIndex].ComName);
                            }
                            else if (index == 1)
                            {
                                SelEntity.Coms.RemoveAt(comIndex);
                            }
                        });
                    });
                    EditorGUILayout.Space();
                }
            });

            //添加组件
            EDButton.CreateBtn("添加组件", 200, 50, () =>
            {
                List <Type> comTyps    = LCReflect.GetClassByType <BaseCom>();
                List <string> showList = new List <string>();
                List <Type> showTyps   = new List <Type>();
                for (int j = 0; j < comTyps.Count; j++)
                {
                    if (CheckContainCom(comTyps[j].FullName))
                    {
                        continue;
                    }
                    showTyps.Add(comTyps[j]);
                    ComAttribute comAttribute = LCReflect.GetTypeAttr <ComAttribute>(comTyps[j]);
                    if (comAttribute != null)
                    {
                        if (comAttribute.GroupName == "")
                        {
                            comAttribute.GroupName = "Default";
                        }
                        showList.Add(comAttribute.GroupName + "/" + comAttribute.ViewName);
                    }
                    else
                    {
                        showList.Add(comTyps[j].FullName);
                    }
                }

                EDPopMenu.CreatePopMenu(showList, (int index) =>
                {
                    Type comType = showTyps[index];
                    if (CheckContainCom(comType.FullName))
                    {
                        Debug.LogError("重复的组件>>>>>>>>" + comType.FullName);
                        return;
                    }

                    EntityComJson comJson = new EntityComJson()
                    {
                        ComName = comType.FullName,
                    };
                    SelEntity.Coms.Add(comJson);
                });
            });

            //保存配置
            EDButton.CreateBtn("保存配置", 200, 50, SaveEntityJsonList);

            //删除实体
            EDButton.CreateBtn("删除实体", 200, 30, () =>
            {
                EDDialog.CreateDialog("删除", "确认删除该实体吗?", (() =>
                {
                    MEntityJsonList.List.Remove(SelEntity);
                    SelEntityChange(null);
                }));
            });
        }