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

116 lines
3.5 KiB
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
//////////////////////////////////////////////////////////////////////////
//
// 文件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
{
2023-10-23 16:48:43 +08:00
public static string CONFIG_DIR = Application.dataPath + "/../../Tool/Luban/";
2023-08-22 19:08:45 +08:00
#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
{
2023-10-23 16:54:35 +08:00
// VersionControlSystem.Checkout(Application.dataPath + "/Code/Scripts/Gameplay/DataTable");
// VersionControlSystem.Checkout(Application.dataPath + "/Config/Data");
2023-08-22 19:08:45 +08:00
#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("导出完成");
}
2023-10-19 15:00:19 +08:00
[MenuItem("Tools/配置工具 _F7", false, (int)NLDMenuID.ConfigExport)]
public static async void ConfigExport()
2023-08-22 19:08:45 +08:00
{
var dir = new DirectoryInfo(CONFIG_DIR);
var SAVE_PATH = dir.FullName + "Datas/";
2023-10-23 19:06:33 +08:00
if (!Directory.Exists(SAVE_PATH))
{
Directory.CreateDirectory(SAVE_PATH);
}
2023-08-22 19:08:45 +08:00
var combiePath = SAVE_PATH + "AConfigList.xlsx";
if (!File.Exists(combiePath))
{
2023-10-24 12:15:31 +08:00
var sid = EditorPrefs.GetString("ConfSid");
var cookies = EditorPrefs.GetString("ConfCookie");
await DownloadConfig(cookies);
2023-08-22 19:08:45 +08:00
}
ConfigWindow.ShowWindow();
}
public static async UniTask DownloadConfig(string cookies)
2023-08-22 19:08:45 +08:00
{
EditorUtility.DisplayProgressBar("配置工具", $"正在下ConfigList....", 0);
2023-10-24 12:15:31 +08:00
var downLoader = new WPExcelDownloader("AConfigList.xlsx",
"e3_AXoAQAavAFIi9riMuy9Q5CMxcHei1", cookies);
2023-08-22 19:08:45 +08:00
var dir = new DirectoryInfo(CONFIG_DIR);
AutoConfig.DownloadConfig.SAVE_PATH = dir.FullName + "Datas/";
var result = await downLoader.StartDownload();
EditorUtility.ClearProgressBar();
}
}