From e16af931f6624da01566311524aaf6956f54a3df Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 04 三月 2026 14:34:42 +0800
Subject: [PATCH] 466 h5版本 资源规则修改 打包修改(未完成 勿拉取)
---
Assets/Editor/ConfigGen/ConfigGenerater.cs | 54 ++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/Assets/Editor/ConfigGen/ConfigGenerater.cs b/Assets/Editor/ConfigGen/ConfigGenerater.cs
index cec9736..63e9cfe 100644
--- a/Assets/Editor/ConfigGen/ConfigGenerater.cs
+++ b/Assets/Editor/ConfigGen/ConfigGenerater.cs
@@ -40,29 +40,55 @@
{
try
{
- // 鑾峰彇鎵�鏈夐厤缃被
- List<string> configClasses = GetAllConfigClasses();
+ // 1. 鑾峰彇鎵�鏈夐厤缃被锛堝幓闄ゆ帓闄ら」锛�
+ List<string> configClasses = GetAllConfigClasses()
+ .Where(c => !ExcludeClassList.Contains(c))
+ .Where(c => !string.IsNullOrEmpty(c) && char.IsUpper(c[0]))
+ .ToList();
- if (System.IO.File.Exists(Path.Combine(Application.dataPath, "fastConfig.txt")))
+ // 2. 鑷姩鐢熸垚 ConfigManager.cs 鐨� LoadConfigs 鏂规硶锛屽叏閮ㄥ紓姝ュ姞杞�
+ string configManagerPath = Path.Combine(Application.dataPath, ConfigManagerPath.Replace("Assets/", ""));
+ var lines = File.ReadAllLines(configManagerPath).ToList();
+
+ // 鏌ユ壘 LoadConfigs 鏂规硶璧锋琛�
+ int startIdx = lines.FindIndex(l => l.Contains("protected async UniTask LoadConfigs()"));
+ int openBrace = lines.FindIndex(startIdx, l => l.Trim() == "{");
+ int endIdx = openBrace;
+ int braceCount = 1;
+ for (int i = openBrace + 1; i < lines.Count; i++)
{
- // 濡傛灉瀛樺湪 fastConfig.txt 鏂囦欢锛岃鍙栧叾涓殑閰嶇疆绫�
- string[] fastConfigs = System.IO.File.ReadAllLines(Path.Combine(Application.dataPath, "fastConfig.txt"));
- ExcludeClassList.AddRange(fastConfigs);
+ if (lines[i].Contains("{")) braceCount++;
+ if (lines[i].Contains("}")) braceCount--;
+ if (braceCount == 0) { endIdx = i; break; }
}
- configClasses = new List<string>(configClasses.Where(config => !ExcludeClassList.Contains(config)));
+ // 鐢熸垚 configTypes 鍒濆鍖栦唬鐮�
+ var configTypeLines = new List<string>();
+ configTypeLines.Add(" // 鑷姩鐢熸垚锛氭敹闆嗘墍鏈夐厤缃被鍨�");
+ configTypeLines.Add(" HashSet<Type> configTypes = new HashSet<Type>() {");
+ for (int i = 0; i < configClasses.Count; i++)
+ {
+ configTypeLines.Add($" typeof({configClasses[i]}){(i < configClasses.Count - 1 ? "," : "")}");
+ }
+ configTypeLines.Add(" };");
- // 鐢熸垚閰嶇疆绠$悊鍣ㄤ唬鐮�
- GenerateConfigManager(configClasses);
-
- Debug.Log($"閰嶇疆绠$悊鍣ㄧ敓鎴愬畬鎴愶紝鍏辨壘鍒� {configClasses.Count} 涓厤缃被: {string.Join(", ", configClasses)}");
-
- // 鍒锋柊璧勬簮
+ // 鏇挎崲鍘熸湁 configTypes 鍒濆鍖栨
+ int configTypesStart = lines.FindIndex(startIdx, l => l.Contains("HashSet<Type> configTypes"));
+ int configTypesEnd = configTypesStart;
+ while (configTypesEnd < lines.Count && !lines[configTypesEnd].Trim().EndsWith("};")) configTypesEnd++;
+ configTypesEnd++;
+ lines.RemoveRange(configTypesStart, configTypesEnd - configTypesStart);
+ lines.InsertRange(configTypesStart, configTypeLines);
+
+ // 淇濆瓨鏂囦欢
+ File.WriteAllLines(configManagerPath, lines);
+
+ Debug.Log($"ConfigManager.cs 鑷姩鐢熸垚 LoadConfigs 閰嶇疆绫诲瀷鎴愬姛锛屽叡 {configClasses.Count} 涓被鍨嬨��");
AssetDatabase.Refresh();
}
catch (Exception ex)
{
- Debug.LogError($"鐢熸垚閰嶇疆绠$悊鍣ㄦ椂鍙戠敓閿欒: {ex.Message}\n{ex.StackTrace}");
+ Debug.LogError($"鑷姩鐢熸垚 ConfigManager.LoadConfigs 鏃跺彂鐢熼敊璇�: {ex.Message}\n{ex.StackTrace}");
}
}
--
Gitblit v1.8.0