Exemple #1
0
    private void OnGUI()
    {
        if (luaTable != null)
        {
            if (moduleInfoList == null)
            {
                if (GUILayout.Button("Load All Modules"))
                {
                    LoadAllModules();
                }
            }
            else
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(position.height * 0.8f));
                EditModulelist();
                EditorGUILayout.EndScrollView();
                if (GUILayout.Button("重新生成 Mvc 文件"))
                {
                    string fileText = luaTable.ToString();
                    FileUtils.SaveTextFile(ViewConfigPath, fileText);
                    Debug.Log("保存成功 \n" + fileText);
                    GeneratedMvcFiles();
                }
            }
        }
        EditorUtils.DrawHorizontalSplitter();
        EditorGUILayout.BeginHorizontal();
        moduleName = EditorGUILayout.TextField("新增模块 模块名:", moduleName);
        if (GUILayout.Button("生成新模块", endButtonWidth))
        {
            if (!ToLuaGenerater.FileNameValid(moduleName, this))
            {
                return;
            }
            if (luaTable.HasTable(moduleName))
            {
                ShowNotification(new GUIContent("该模块已经存在"));
                return;
            }

            Dictionary <string, object> table = luaTable.SetTable(moduleName);
            table.Add("name", moduleName);
            GeneratedModuleFolders(moduleName);

            LoadAllModules();
        }
        EditorGUILayout.EndHorizontal();
    }