From 766beffdf3552ef144ebc964f6a34e73d8d7a155 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 03 七月 2025 17:14:49 +0800
Subject: [PATCH] 18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建 配置表问题

---
 Assets/Editor/ConfigGen/ConfigGenerater.cs |  195 ++++++++++++++++--------------------------------
 1 files changed, 65 insertions(+), 130 deletions(-)

diff --git a/Assets/Editor/ConfigGen/ConfigGenerater.cs b/Assets/Editor/ConfigGen/ConfigGenerater.cs
index 3cce081..f24a1fa 100644
--- a/Assets/Editor/ConfigGen/ConfigGenerater.cs
+++ b/Assets/Editor/ConfigGen/ConfigGenerater.cs
@@ -21,56 +21,6 @@
         //  鐗规畩琛ㄦ牸
         "InitialFunctionConfig",
         "PriorLanguageConfig",
-
-        //  姝e父璇诲彇灏忎簬5ms鐨勮〃 浣跨敤lazyload
-        "AppointItemConfig",
-        "AudioConfig",
-        "ChatBubbleBoxConfig",
-        "ChestsConfig",
-        "CTGSelectItemConfig",
-        "DailyLivenessRewardConfig",
-        "DailyQuestConfig",
-        "DailyQuestOpenTimeConfig",
-        "DienstgradConfig",
-        "DirtyNameConfig",
-        "EffectConfig",
-        "EmojiPackConfig",
-        "EquipPlaceMapConfig",
-        "FamilyConfig",
-        "FamilyEmblemConfig",
-        "FirstGoldConfig",
-        "FrameAnimationConfig",
-        "FuncConfigConfig",
-        "FuncOpenLVConfig",
-        "FunctionTeamSetConfig",
-        "GetItemWaysConfig",
-        "GmCmdConfig",
-        "GuideConfig",
-        "HeroAwakeConfig",
-        "HeroBreakConfig",
-        "HeroConfig",
-        "HeroFetterConfig",
-        "HeroQualityAwakeConfig",
-        "HeroQualityBreakConfig",
-        "HeroQualityConfig",
-        "HeroSkinConfig",
-        "HeroTalentConfig",
-        "IconConfig",
-        "ItemConfig",
-        "KickOutReasonConfig",
-        "LanguageConfig",
-        "MailConfig",
-        "PlayerFaceConfig",
-        "PlayerFacePicConfig",
-        "PlayerPropertyConfig",
-        "priorbundleConfig",
-        "RealmConfig",
-        "RealmLVUPTaskConfig",
-        "RichTextMsgReplaceConfig",
-        "RuleConfig",
-        "SkillConfig",
-        "TaskConfig",
-        "TreasureCntAwardConfig",
     };
 
     [MenuItem("Tools/鎵嬪姩鍒锋柊")]
@@ -89,7 +39,14 @@
         {
             // 鑾峰彇鎵�鏈夐厤缃被
             List<string> configClasses = GetAllConfigClasses();
-            
+
+            if (System.IO.File.Exists(Path.Combine(Application.dataPath, "fastConfig.txt")))
+            {
+                // 濡傛灉瀛樺湪 fastConfig.txt 鏂囦欢锛岃鍙栧叾涓殑閰嶇疆绫�
+                string[] fastConfigs = System.IO.File.ReadAllLines(Path.Combine(Application.dataPath, "fastConfig.txt"));
+                ExcludeClassList.AddRange(fastConfigs);
+            }
+
             configClasses = new List<string>(configClasses.Where(config => !ExcludeClassList.Contains(config)));
 
             // 鐢熸垚閰嶇疆绠$悊鍣ㄤ唬鐮�
@@ -177,8 +134,8 @@
     private static string GenerateFullConfigManagerCode(List<string> configClasses)
     {
         StringBuilder sb = new StringBuilder();
-        
-        // 娣诲姞鍛藉悕绌洪棿寮曠敤
+
+        // 澶撮儴鍛藉悕绌洪棿
         sb.AppendLine("using System;");
         sb.AppendLine("using System.Collections.Generic;");
         sb.AppendLine("using UnityEngine;");
@@ -188,8 +145,6 @@
         sb.AppendLine();
         sb.AppendLine("public class ConfigManager : ManagerBase<ConfigManager>");
         sb.AppendLine("{");
-        
-        // 娣诲姞灞炴�у拰瀛楁
         sb.AppendLine("    public bool isLoadFinished");
         sb.AppendLine("    {");
         sb.AppendLine("        get;");
@@ -198,77 +153,79 @@
         sb.AppendLine();
         sb.AppendLine("    private float loadingProgress = 0f;");
         sb.AppendLine();
-        
-        // 娣诲姞鍒濆鍖栨柟娉�
         sb.AppendLine("    public override void Init()");
         sb.AppendLine("    {");
         sb.AppendLine("        base.Init();");
         sb.AppendLine("        InitConfigs();");
         sb.AppendLine("    }");
         sb.AppendLine();
-        
-        // 娣诲姞閰嶇疆鍒濆鍖栨柟娉�
         sb.AppendLine("    public virtual async UniTask InitConfigs()");
         sb.AppendLine("    {");
         sb.AppendLine("        // 鍔犺浇閰嶇疆鏂囦欢");
         sb.AppendLine("        await LoadConfigs();");
         sb.AppendLine("    }");
         sb.AppendLine();
-        
-        // 娣诲姞LoadConfigs鏂规硶
         sb.AppendLine("    protected async UniTask LoadConfigs()");
         sb.AppendLine("    {");
         sb.AppendLine("        loadingProgress = 0f;");
         sb.AppendLine("        isLoadFinished = false;");
         sb.AppendLine();
         sb.AppendLine("        // 鍔犺浇閰嶇疆鏂囦欢");
-        
-        // 濡傛灉鏈夐厤缃被锛屾坊鍔犺繘搴﹁窡韪唬鐮�
-        if (configClasses.Count > 0)
+        sb.AppendLine($"        int totalConfigs = {configClasses.Count};");
+        sb.AppendLine("        List<Type> configTypes = new List<Type>() {");
+        for (int i = 0; i < configClasses.Count; i++)
         {
-            sb.AppendLine($"        int totalConfigs = {configClasses.Count};");
-            
-            // 浣跨敤鏁扮粍鍜屽惊鐜姞杞介厤缃�
-            sb.AppendLine("        Type[] configTypes = new Type[] {");
-            for (int i = 0; i < configClasses.Count; i++)
-            {
-                sb.Append($"            typeof({configClasses[i]})");
-                sb.AppendLine(i < configClasses.Count - 1 ? "," : "");
-            }
-            sb.AppendLine("        };");
-            sb.AppendLine();
-            sb.AppendLine("#if UNITY_EDITOR");
-            sb.AppendLine("        List<string> fastName = new List<string>();");
-            sb.AppendLine("#endif");
-
-
-            sb.AppendLine("        // 閫愪釜鍔犺浇閰嶇疆骞舵洿鏂拌繘搴�");
-            sb.AppendLine("        for (int i = 0; i < configTypes.Length; i++)");
-            sb.AppendLine("        {");
-            sb.AppendLine("            var sw = System.Diagnostics.Stopwatch.StartNew();");
-            sb.AppendLine("            LoadConfigByType(configTypes[i]);");
-            sb.AppendLine("            sw.Stop();");
-            sb.AppendLine("#if UNITY_EDITOR");
-            sb.AppendLine("            if (sw.ElapsedMilliseconds >= 100)");
-            sb.AppendLine("            {");
-            sb.AppendLine("                Debug.LogError($\"鍔犺浇閰嶇疆 {configTypes[i].Name} 鑰楁椂杈冮暱: {sw.ElapsedMilliseconds} ms\");");
-            sb.AppendLine("            }");
-            sb.AppendLine("            else if (sw.ElapsedMilliseconds <= 5)");
-            sb.AppendLine("            {");
-            sb.AppendLine("                fastName.Add(configTypes[i].Name);");
-            sb.AppendLine("            }");
-            sb.AppendLine("            Debug.Log($\"鍔犺浇閰嶇疆: {configTypes[i].Name} 鐢ㄦ椂: {sw.ElapsedMilliseconds} ms\");");
-            sb.AppendLine("#endif");
-            sb.AppendLine("            loadingProgress = (float)(i + 1) / totalConfigs;");
-            sb.AppendLine("        }");
+            sb.Append($"            typeof({configClasses[i]})");
+            sb.AppendLine(i < configClasses.Count - 1 ? "," : "");
         }
-        else
-        {
-            Debug.LogError("娌℃湁鎵惧埌閰嶇疆绫� : " + configClasses.Count);
-        }
-        
+        sb.AppendLine("        };");
+        sb.AppendLine();
+        sb.AppendLine("#if UNITY_EDITOR");
+        sb.AppendLine("        HashSet<Type> configHashSet = new HashSet<Type>();");
+        sb.AppendLine("        if (System.IO.File.Exists(Application.dataPath + \"/fastConfig.txt\"))");
+        sb.AppendLine("        {");
+        sb.AppendLine("            string[] strConfgsArr = System.IO.File.ReadAllLines(Application.dataPath + \"/fastConfig.txt\");");
+        sb.AppendLine("            foreach (string str in strConfgsArr)");
+        sb.AppendLine("            {");
+        sb.AppendLine("                Type tpy = Type.GetType(str);");
+        sb.AppendLine("                configHashSet.Add(tpy);");
+        sb.AppendLine("            }");
+        sb.AppendLine("        }");
+        sb.AppendLine("        //  缂栬緫鍣ㄤ笅鍔犲叆 璇勪及鍔犺浇鏃跺父");
+        sb.AppendLine("        configTypes.AddRange(configHashSet);");
+        sb.AppendLine("        List<string> fastName = new List<string>();");
+        sb.AppendLine("#endif");
+        sb.AppendLine("        // 閫愪釜鍔犺浇閰嶇疆骞舵洿鏂拌繘搴�");
+        sb.AppendLine("        for (int i = 0; i < configTypes.Count; i++)");
+        sb.AppendLine("        {");
+        sb.AppendLine("            var sw = System.Diagnostics.Stopwatch.StartNew();");
+        sb.AppendLine("            LoadConfigByType(configTypes[i]);");
+        sb.AppendLine("            sw.Stop();");
+        sb.AppendLine("#if UNITY_EDITOR");
+        sb.AppendLine("            if (sw.ElapsedMilliseconds >= 100)");
+        sb.AppendLine("            {");
+        sb.AppendLine("                Debug.LogError($\"鍔犺浇閰嶇疆 {configTypes[i].Name} 鑰楁椂杈冮暱: {sw.ElapsedMilliseconds} ms\");");
+        sb.AppendLine("            }");
+        sb.AppendLine("            else if (sw.ElapsedMilliseconds <= 5)");
+        sb.AppendLine("            {");
+        sb.AppendLine("                fastName.Add(configTypes[i].Name);");
+        sb.AppendLine("            }");
+        sb.AppendLine("            Debug.Log($\"鍔犺浇閰嶇疆: {configTypes[i].Name} 鐢ㄦ椂: {sw.ElapsedMilliseconds} ms\");");
+        sb.AppendLine("#endif");
+        sb.AppendLine("            loadingProgress = (float)(i + 1) / totalConfigs;");
+        sb.AppendLine("        }");
         sb.AppendLine("#if UNITY_EDITOR");
         sb.AppendLine("        System.IO.File.WriteAllText(Application.dataPath + \"/fastConfig.txt\", string.Join(\"\\n\", fastName));");
+        sb.AppendLine();
+        sb.AppendLine("        //鍔犺浇瀹屽悗鍗歌浇");
+        sb.AppendLine("        foreach (var configType in configTypes)");
+        sb.AppendLine("        {");
+        sb.AppendLine("            var methodInfo = configType.GetMethod(\"ForceRelease\", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy);");
+        sb.AppendLine("            if (methodInfo != null)");
+        sb.AppendLine("            {");
+        sb.AppendLine("                methodInfo.Invoke(null, null);");
+        sb.AppendLine("            }");
+        sb.AppendLine("        }");
         sb.AppendLine("#endif");
         sb.AppendLine();
         sb.AppendLine("        // 鍔犺浇瀹屾垚鍚庤缃甶sLoadFinished涓簍rue");
@@ -276,8 +233,6 @@
         sb.AppendLine("        isLoadFinished = true;");
         sb.AppendLine("    }");
         sb.AppendLine();
-        
-        // 娣诲姞LoadConfigByType鏂规硶
         sb.AppendLine("    public void LoadConfigByType(Type configType)");
         sb.AppendLine("    {");
         sb.AppendLine("        string configName = configType.Name;");
@@ -312,8 +267,6 @@
         sb.AppendLine("        }");
         sb.AppendLine("    }");
         sb.AppendLine();
-        
-        // 娣诲姞娉涘瀷LoadConfig鏂规硶
         sb.AppendLine("    private async UniTask LoadConfig<T>() where T : class");
         sb.AppendLine("    {");
         sb.AppendLine("        string configName = typeof(T).Name;");
@@ -345,15 +298,11 @@
         sb.AppendLine("        }");
         sb.AppendLine("    }");
         sb.AppendLine();
-        
-        // 娣诲姞GetLoadingProgress鏂规硶
         sb.AppendLine("    public float GetLoadingProgress()");
         sb.AppendLine("    {");
         sb.AppendLine("        return loadingProgress;");
         sb.AppendLine("    }");
         sb.AppendLine();
-        
-        // 娣诲姞ClearConfigDictionary鏂规硶
         sb.AppendLine("    private void ClearConfigDictionary<T>() where T : class");
         sb.AppendLine("    {");
         sb.AppendLine("        // 閲嶇疆 T 鍒濆鍖栫姸鎬�");
@@ -364,30 +313,16 @@
         sb.AppendLine("        }");
         sb.AppendLine("    }");
         sb.AppendLine();
-        
-        // 娣诲姞Release鏂规硶
         sb.AppendLine("    public override void Release()");
         sb.AppendLine("    {");
-        
-        if (configClasses.Count > 0)
+        foreach (string className in configClasses)
         {
-            foreach (string className in configClasses)
-            {
-                // 娓呯┖瀛楀吀
-                sb.AppendLine($"        // 娓呯┖ {className} 瀛楀吀");
-                sb.AppendLine($"        ClearConfigDictionary<{className}>();");
-            }
+            sb.AppendLine($"        // 娓呯┖ {className} 瀛楀吀");
+            sb.AppendLine($"        ClearConfigDictionary<{className}>();");
         }
-        else
-        {
-            sb.AppendLine("        // 娌℃湁鎵惧埌閰嶇疆绫�");
-        }
-        
         sb.AppendLine("    }");
-        
-        // 缁撴潫绫诲畾涔�
         sb.AppendLine("}");
-        
+
         return sb.ToString();
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0