三国卡牌客户端基础资源仓库
Assets/Editor/ConfigGen/ConfigGenerater.cs
@@ -18,8 +18,59 @@
    
    private static List<string> ExcludeClassList = new List<string>()
    {
        //  特殊表格
        "InitialFunctionConfig",
        "PriorLanguageConfig",
        //  正常读取小于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/手动刷新")]
@@ -186,10 +237,28 @@
            }
            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("            await 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("        }");
        }
@@ -198,6 +267,9 @@
            Debug.LogError("没有找到配置类 : " + configClasses.Count);
        }
        
        sb.AppendLine("#if UNITY_EDITOR");
        sb.AppendLine("        System.IO.File.WriteAllText(Application.dataPath + \"/fastConfig.txt\", string.Join(\"\\n\", fastName));");
        sb.AppendLine("#endif");
        sb.AppendLine();
        sb.AppendLine("        // 加载完成后设置isLoadFinished为true");
        sb.AppendLine("        loadingProgress = 1f;");
@@ -213,10 +285,10 @@
        sb.AppendLine("        {");
        sb.AppendLine("            configName = configName.Substring(0, configName.Length - 6);");
        sb.AppendLine("        }");
        sb.AppendLine("        TextAsset textAsset = ResManager.Instance.LoadAsset<TextAsset>(\"Config\", configName);");
        sb.AppendLine("        if (textAsset != null)");
        sb.AppendLine("        string[] texts = ResManager.Instance.LoadConfig(configName);");
        sb.AppendLine("        if (texts != null)");
        sb.AppendLine("        {");
        sb.AppendLine("            string[] lines = textAsset.text.Split('\\n');");
        sb.AppendLine("            string[] lines = texts;");
        sb.AppendLine("            var methodInfo = configType.GetMethod(\"Init\", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy);");
        sb.AppendLine("            if (methodInfo != null)");
        sb.AppendLine("            {");
@@ -246,10 +318,10 @@
        sb.AppendLine("    {");
        sb.AppendLine("        string configName = typeof(T).Name;");
        sb.AppendLine();
        sb.AppendLine("        TextAsset textAsset = ResManager.Instance.LoadAsset<TextAsset>(\"Config\", configName);");
        sb.AppendLine("        if (textAsset != null)");
        sb.AppendLine("        string[] texts = ResManager.Instance.LoadConfig(configName);");
        sb.AppendLine("        if (texts != null)");
        sb.AppendLine("        {");
        sb.AppendLine("            string[] lines = textAsset.text.Split('\\n');");
        sb.AppendLine("            string[] lines = texts;");
        sb.AppendLine("            var methodInfo = typeof(T).GetMethod(\"Init\", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);");
        sb.AppendLine("            if (methodInfo != null)");
        sb.AppendLine("            {");