SK_LongZhu
DESKTOP-RH64908\Administrator 2025-08-13 15:47:23 +08:00
parent a25b53a9b1
commit cf288e1915
1 changed files with 29 additions and 20 deletions

View File

@ -13,7 +13,7 @@ using UnityEngine;
namespace GameEditor.Core.DataConfig
{
public class ConfigExportWindow:EditorWindow
public class ConfigExportWindow : EditorWindow
{
static string m_ExcelPath;
static string m_BattleConfigPath;
@ -70,7 +70,7 @@ namespace GameEditor.Core.DataConfig
public static void PyCallBuildData()
{
string[] s = System.Environment.GetCommandLineArgs();//获取命令行参数
int _index = s.Length - 1;
int _index = s.Length - 1;
// 导表
DataConfigWindow.excelALLConfig(false, "E:/Git/data_execl/" + s[_index] + "/base_data");
}
@ -102,7 +102,7 @@ namespace GameEditor.Core.DataConfig
// 保存数据
EditorPrefs.SetString("m_ExcelPath", m_ExcelPath);
EditorPrefs.SetString("m_BattleConfigPath", m_BattleConfigPath);
EditorPrefs.SetString("m_BattleConfigRootPath",m_BattleConfigRootPath);
EditorPrefs.SetString("m_BattleConfigRootPath", m_BattleConfigRootPath);
EditorPrefs.SetString("m_Bench", m_Bench);
}
@ -178,14 +178,22 @@ namespace GameEditor.Core.DataConfig
EditorGUILayout.Space();
EditorGUILayout.LabelField("请选择分支:");
if(m_Files != null && m_Files.Length != 0)
if (m_Files != null && m_Files.Length != 0)
{
for (int i = 0; i < m_Files.Length; i++)
{
EditorGUILayout.BeginHorizontal();
m_Choose[i] = EditorGUILayout.ToggleLeft(m_Files[i], m_Choose[i]);
i++;
if (i < m_Files.Length)
{
m_Choose[i] = EditorGUILayout.ToggleLeft(m_Files[i], m_Choose[i]);
}
EditorGUILayout.EndHorizontal();
}
}
else {
else
{
EditorGUILayout.LabelField("未找到分支");
}
EditorGUILayout.EndVertical();
@ -204,11 +212,11 @@ namespace GameEditor.Core.DataConfig
// 导表
DataConfigWindow.excelALLConfig(true, m_Bench + "/base_data");
}
if(m_CurServerBattlePath!= null)
if (m_CurServerBattlePath != null)
{
EditorGUILayout.LabelField("战斗数据表同步根路径:");
m_BattleConfigRootPath = EditorGUILayout.TextField("", m_BattleConfigRootPath);
EditorGUILayout.LabelField("目标战斗校验服文件夹为:"+m_CurServerBattlePath);
EditorGUILayout.LabelField("目标战斗校验服文件夹为:" + m_CurServerBattlePath);
if (GUILayout.Button("同步到战斗校验服并提交", GUILayout.Height(40f)))
{
UpdateSVNBattleData();
@ -223,7 +231,7 @@ namespace GameEditor.Core.DataConfig
EditorGUILayout.LabelField("战斗数据表同步路径:");
m_BattleConfigPath = EditorGUILayout.TextField("", m_BattleConfigPath);
if (GUILayout.Button("同步战斗数据表", GUILayout.Height(40f)))
{
CopyBattleFiles(m_BattleConfigPath);
@ -259,7 +267,7 @@ namespace GameEditor.Core.DataConfig
// 将战斗相关数据表文件同步到目标文件夹
void CopyBattleFiles(string targetPath)
{
UnityEngine.Debug.Log("同步战斗文件到目标路径:"+ targetPath);
UnityEngine.Debug.Log("同步战斗文件到目标路径:" + targetPath);
string sourcePath = Application.dataPath + "/ManagedResources/~lua/Config/Data/";
for (int i = 0; i < battleConfigList.Length; i++)
{
@ -291,7 +299,7 @@ namespace GameEditor.Core.DataConfig
FileStream fs = null;
try
{
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None);
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None);
inUse = false;
}
catch { }
@ -301,10 +309,10 @@ namespace GameEditor.Core.DataConfig
}
return inUse;
}
public static void excelALLConfig(bool isIncrement, string path)
{
if(path == "")
if (path == "")
{
path = DataConfigSetting.execlDir;
}
@ -402,7 +410,7 @@ namespace GameEditor.Core.DataConfig
}
string crc = FileToCRC32.GetFileCRC32(item);
bool isChanged = !record.ContainsKey(itemName) || record[itemName] != crc;
bool isChanged = !record.ContainsKey(itemName) || record[itemName] != crc;
if (!isIncrement || (isIncrement && isChanged))
{
lock (lockObj)
@ -437,7 +445,7 @@ namespace GameEditor.Core.DataConfig
{
excelALLConfig(true, DataConfigSetting.execlDir);
}
private static void exportSheet(DataConfigSetting setting, string path, bool isIncrement)
{
string fileExt = Path.GetExtension(path).ToLower();
@ -488,7 +496,7 @@ namespace GameEditor.Core.DataConfig
{
Setting = 0,
Excel = 1,
// Check = 2,
// Check = 2,
}
public string[] TabNames = new string[]
{
@ -521,16 +529,16 @@ namespace GameEditor.Core.DataConfig
void OnGUI()
{
if(excels == null)
if (excels == null)
{
excels = new List<DataExcelSetting>();
if (!string.IsNullOrEmpty(DataConfigSetting.execlDir) && Directory.Exists(DataConfigSetting.execlDir))
{
string[] files = Directory.GetFiles(DataConfigSetting.execlDir, "*.*", SearchOption.AllDirectories);
EditorUtility.DisplayProgressBar("Loading", "loading excel", 0f);
for(int i =0;i<files.Length;i++)
for (int i = 0; i < files.Length; i++)
{
EditorUtility.DisplayProgressBar("Loading", "loading excel:"+files[i], ((float)i)/files.Length);
EditorUtility.DisplayProgressBar("Loading", "loading excel:" + files[i], ((float)i) / files.Length);
string fileExt = Path.GetExtension(files[i]).ToLower();
if (fileExt == ".xlsx" || fileExt == ".xls")
{
@ -551,11 +559,12 @@ namespace GameEditor.Core.DataConfig
tabType = (TabType)GUILayout.Toolbar((int)tabType, TabNames, "LargeButton", GUILayout.Width(toolbarWidth));
}
GUILayout.EndHorizontal();
Rect contentRect = new Rect(2, 40, position.width-4, position.height - 60);
Rect contentRect = new Rect(2, 40, position.width - 4, position.height - 60);
if (tabType == TabType.Setting)
{
settingTab.OnGUI(contentRect);
} else if (tabType == TabType.Excel)
}
else if (tabType == TabType.Excel)
{
excelTab.OnGUI(contentRect);
}