Esempio n. 1
0
    private void DrawFieldData(TableConfigOtherInfo info)
    {
        pos1 = GUILayout.BeginScrollView(pos1, "CurveEditorBackground");
        List <TableConfigFieldInfo> list = new List <TableConfigFieldInfo>(info.fieldInfoDic.Values);

        for (int i = 0; i < list.Count; i++)
        {
            TableConfigFieldInfo temp = list[i];
            temp = (TableConfigFieldInfo)EditorDrawGUIUtil.DrawBaseValue("◆", temp);
            Type tempType = TableConfigTool.ConfigFieldValueType2Type(temp.fieldValueType);
            if (temp.defultValue == null || tempType.FullName != temp.defultValue.GetType().FullName)
            {
                temp.defultValue = ReflectionUtils.CreateDefultInstance(tempType);
            }
            GUILayout.Space(3);
            if (GUILayout.Button("Delete"))
            {
                if (EditorUtility.DisplayDialog("警告", "是否删除字段", "OK", "Cancel"))
                {
                    // info.fieldInfoDic.Remove(temp.fieldName);
                    list.Remove(temp);
                }
            }

            GUILayout.Space(6);
        }
        GUILayout.EndScrollView();
        info.fieldInfoDic.Clear();
        for (int i = 0; i < list.Count; i++)
        {
            TableConfigFieldInfo temp = list[i];
            info.fieldInfoDic.Add(temp.fieldName, temp);
        }
    }
Esempio n. 2
0
    private void CheckEditConfigData()
    {
        TableConfigOtherInfo infos = TableConfigBase.tableConfigOtherInfo[chooseFileName];
        List <ConfigRowData> datas = currentEditConfigData.configRowDataList[index];
        List <string>        fs    = new List <string>(infos.fieldInfoDic.Keys);

        foreach (var item in fs)
        {
            if (!currentEditConfigData.IsHaveRow(item))
            {
                currentEditConfigData.AddRow(item, infos.fieldInfoDic[item].defultValue);
                return;
            }
        }

        for (int i = 0; i < datas.Count; i++)
        {
            ConfigRowData d = datas[i];
            if (!infos.fieldInfoDic.ContainsKey(d.fieldName))
            {
                currentEditConfigData.RemoveFieldValue(d.fieldName);
                break;
            }
            TableConfigFieldInfo field = infos.fieldInfoDic[d.fieldName];
            Type tempType = TableConfigTool.ConfigFieldValueType2Type(field.fieldValueType);
            if (d.value == null || tempType.FullName != d.value.GetType().FullName)
            {
                d.value = field.defultValue;
                break;
            }
        }
    }
Esempio n. 3
0
    void OnGUI()
    {
        toolbarOption0 = GUILayout.Toolbar(toolbarOption0, toolbarTexts0, GUILayout.Width(Screen.width));
        switch (toolbarOption0)
        {
        case 0:
            GUILayout.Space(8);
            ChooseFile();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            toolbarOption = GUILayout.Toolbar(toolbarOption, toolbarTexts, GUILayout.Width(Screen.width * 3 / 4f));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(5);

            switch (toolbarOption)
            {
            case 0:
                DrawTableDataGUI();

                break;

            case 1:
                DrawFields();
                break;
            }

            GUILayout.FlexibleSpace();
            GUILayout.Space(5);
            if (GUILayout.Button("保存配置文件"))
            {
                CheckEditConfigData();
                TableConfigOtherInfo infos = TableConfigBase.tableConfigOtherInfo[chooseFileName];
                string content             = TableConfigTool.ConfigInfo2TableText(infos, currentEditConfigData);
                string path = CreateConfigClassEditor.SaveConfigFilePath + "/" + chooseFileName + ".txt";
                FileUtils.CreateTextFile(path, content);
                CreateConfigClassEditor.CreateConfigClassFile(content, chooseFileName);
                AssetDatabase.Refresh();
            }
            break;

        case 1:
            GUILayout.Space(5);
            NewTableConfig();
            break;
        }
    }
Esempio n. 4
0
    private void NewTableConfig()
    {
        GUILayout.BeginHorizontal("box");
        newFileName = EditorDrawGUIUtil.DrawBaseValue("新建配置文件:", newFileName).ToString();
        if (GUILayout.Button("确定", GUILayout.Width(50)))
        {
            if (ResourcePathManager.ContainsFileName(newFileName) || string.IsNullOrEmpty(newFileName))
            {
                EditorUtility.DisplayDialog("警告", "名字不能为空或重复", "OK");
            }
            else
            {
                chooseFileName = newFileName;
                fileNames.Add(newFileName);
            }
        }

        GUILayout.EndHorizontal();

        if (string.IsNullOrEmpty(newFileName))
        {
            return;
        }
        if (ResourcePathManager.ContainsFileName(newFileName))
        {
            EditorGUILayout.HelpBox("文件名重复!!", MessageType.Error);
            return;
        }
        if (newConfigInfo == null)
        {
            newConfigInfo = new TableConfigOtherInfo();
        }

        newConfigInfo.configDescription = EditorDrawGUIUtil.DrawBaseValue("配置文件描述:", newConfigInfo.configDescription).ToString();
        GUILayout.Space(5);
        GUILayout.BeginHorizontal("box");
        GUILayout.Box("添加字段:");
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("+", GUILayout.Width(50)))
        {
            TableConfigFieldInfo f = new TableConfigFieldInfo();
            f.fieldName = "NewField" + newConfigInfo.fieldInfoDic.Count;
            while (newConfigInfo.fieldInfoDic.ContainsKey(f.fieldName))
            {
                f.fieldName += "_0";
            }
            newConfigInfo.fieldInfoDic.Add(f.fieldName, f);
        }
        GUILayout.EndHorizontal();

        DrawFieldData(newConfigInfo);

        if (newConfigInfo.fieldInfoDic.Count > 0 && GUILayout.Button("创建"))
        {
            GlobalEvent.AddEvent(EditorGlobalEventEnum.OnResourcesAssetsChange, (t) =>
            {
                Debug.Log("OnResourcesAssetsChange");
                AssetsSortManagement.SetLayer(newFileName, configLayerName);
                AssetsSortManagement.Save();

                newFileName   = "";
                newConfigInfo = null;
            }, true);
            string content = TableConfigTool.ConfigInfo2TableText(newConfigInfo, null);
            string path    = CreateConfigClassEditor.SaveConfigFilePath + "/" + newFileName + ".txt";
            FileUtils.CreateTextFile(path, content);
            CreateConfigClassEditor.CreateConfigClassFile(content, newFileName);
            AssetDatabase.Refresh();
        }
    }