////////////////////////////////////////////////////////////////////////// // // 文件:Assets/Editor/Tools/ConfigTools.cs // 作者:Xoen Xie // 时间:2023/07/25 // 描述:Config tools // 说明: // ////////////////////////////////////////////////////////////////////////// using UnityEditor; using UnityEngine; using System.IO; using System.Xml; using System.Text; using System.Diagnostics; using System; using AutoConfig; using Cysharp.Threading.Tasks; public static class ConfigTools { public static string CONFIG_DIR = Application.dataPath + "/../../../NLDMisc/config/Datas"; #if UNITY_EDITOR_OSX //static string PYTHON_NAME = "python3"; static string CMD_NAME = "sh"; static string CMD_PARAM = "mac_client_export.sh " + Application.dataPath; #elif UNITY_EDITOR_WIN //static string PYTHON_NAME = "python"; static string CMD_NAME = "cmd.exe"; static string CMD_PARAM = "gen_code_json.bat"; #endif public static void ConfigExportClient() { EditorUtility.DisplayProgressBar("配置工具", "正在导出配置到【Client】", 0); try { // VersionControlSystem.Checkout(Application.dataPath + "/Code/Scripts/Gameplay/DataTable"); // VersionControlSystem.Checkout(Application.dataPath + "/Config/Data"); #if UNITY_EDITOR_WIN var dirInfo = new DirectoryInfo(CONFIG_DIR); EditorUtil.StartProcess(dirInfo.FullName + CMD_PARAM, Application.dataPath, CONFIG_DIR); #else EditorUtil.StartProcess(CMD_NAME, CMD_PARAM, CONFIG_DIR); #endif AssetDatabase.Refresh(); } catch (Exception e) { UnityEngine.Debug.LogError("出现异常,message=" + e.Message + "\n,trace=" + e.StackTrace); } EditorUtility.ClearProgressBar(); UnityEngine.Debug.Log("导出完成"); } public static void ConfigExportServer() { EditorUtility.DisplayProgressBar("配置工具", "正在导出配置到【Server】", 0); try { EditorUtil.StartProcess(CMD_NAME, "mac_server_export.sh", CONFIG_DIR); } catch (Exception e) { UnityEngine.Debug.LogError("出现异常,message=" + e.Message + "\n,trace=" + e.StackTrace); } EditorUtility.ClearProgressBar(); UnityEngine.Debug.Log("导出完成"); } [MenuItem("Tools/*配置工具/数据导出工具 _F7", false, (int)NLDMenuID.ConfigExport)] public static void ConfigExport() { ConfigWindow.ShowWindow(); } }