Assets/Editor/Tool/ConfigClassGenerate.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Assets/Editor/Tool/TableTool.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Assets/Editor/Tool/ConfigClassGenerate.cs
@@ -43,7 +43,7 @@ } } public static void CreateConfigClass(FileInfo fileInfo) public static void CreateConfigClass(FileInfo fileInfo, bool isIL = false) { var lines = File.ReadAllLines(fileInfo.FullName); if (lines.Length > 2) @@ -77,7 +77,7 @@ filedContent = string.Join("\r\n\t", fieldFulls.ToArray()); readContent = string.Join("\r\n\r\n\t\t\t", readFulls.ToArray()); CreatNewConfigClass(fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'))); CreatNewConfigClass(fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.')), isIL); } } @@ -251,12 +251,21 @@ } } static string configClassPath = "Assets" + "/" + "Scripts/Core/GameEngine/Model/Config"; static string configClassPath = "Assets/Scripts/Core/GameEngine/Model/Config"; static string configILClassPath = "LogicProject/Src/Config"; static string templatePath = "Assets/Editor/ScriptTemplate/ConfigDataTemplate.txt"; public static void CreatNewConfigClass(string _name) public static void CreatNewConfigClass(string _name, bool isIL) { var newConfigPath = configClassPath + string.Format("/{0}Config.cs", _name); string newConfigPath; if (isIL) { newConfigPath = configILClassPath + string.Format("/IL{0}Config.cs", _name); } else { newConfigPath = configClassPath + string.Format("/{0}Config.cs", _name); } AssetDatabase.DeleteAsset(newConfigPath); UnityEngine.Object o = CreateScriptAssetFromTemplate(newConfigPath, templatePath); ProjectWindowUtil.ShowCreatedAsset(o); Assets/Editor/Tool/TableTool.cs
@@ -11,11 +11,13 @@ public class TableTool : EditorWindow { public static string configOutPutPath = UnityEngine.Application.dataPath + "/StreamingAssets/Config"; public static string configOutPutPath; static bool isIL = false; // 导出表代码是否IL使用 [UnityEditor.MenuItem("策划工具/导出策划表到游戏工程")] static void Init() { configOutPutPath = UnityEngine.Application.dataPath + "/StreamingAssets/Config"; window = GetWindow(typeof(TableTool), true, "策划导表工具") as TableTool; window.position = new Rect(UnityEngine.Screen.width / 2, UnityEngine.Screen.height / 2, 300, 700); window.Show(); @@ -65,6 +67,7 @@ GUILayout.BeginHorizontal(); if (GUILayout.Button("导出表")) { isIL = false; ReadAllTxt(); GenAllClass(); MessageBox.Show("导出表成功!"); @@ -72,7 +75,18 @@ } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); if (GUILayout.Button("导出IL表")) { isIL = true; ReadAllTxt(); GenAllClass(); MessageBox.Show("导出IL表成功!"); AssetDatabase.Refresh(); isIL = false; } GUILayout.EndHorizontal(); if (GUILayout.Button("选择路径")) { @@ -89,6 +103,7 @@ #endif } GUIUtility.ExitGUI(); } private void ShowTableNames() @@ -262,7 +277,7 @@ } FileStream fileStream = _tableNameLst[i].fileInfo.OpenRead(); StreamReader sr = new StreamReader(fileStream, Encoding.Default); CreateConfigClassFile.CreateConfigClass(_tableNameLst[i].fileInfo); CreateConfigClassFile.CreateConfigClass(_tableNameLst[i].fileInfo, isIL); sr.Dispose(); sr.Close(); }