NLDClient-yudde/ProjectNLD/Assets/Editor/Tools/AutoConfig/ConfigTools.cs

109 lines
3.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////
//
// 文件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 + "/../../Tool/Luban/";
#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()
{
var dir = new DirectoryInfo(CONFIG_DIR);
var SAVE_PATH = dir.FullName + "Datas/";
var combiePath = SAVE_PATH + "AConfigList.xlsx";
if (!File.Exists(combiePath))
{
DownloadConfig();
}
ConfigWindow.ShowWindow();
}
public static async void DownloadConfig()
{
EditorUtility.DisplayProgressBar("配置工具", $"正在下ConfigList....", 0);
var downLoader = new WPExcelDownloader("AConfigList.xlsx", "e3_AQIA8QbmAKEFwoGRFPhT9uizRsOaA");
var dir = new DirectoryInfo(CONFIG_DIR);
AutoConfig.DownloadConfig.SAVE_PATH = dir.FullName + "Datas/";
var result = await downLoader.StartDownload();
EditorUtility.ClearProgressBar();
}
}