0312 性能优化: 表代码生成去掉部分json,去掉玩家名屏蔽表
| | |
| | | AssetDatabase.Refresh();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 批量重新生成所有配置解析类,无需在 Project 窗口手动全选。
|
| | | /// 会跳过 ConfigGenerater.ExcludeClassList 中登记的表(如 DirtyWord)。
|
| | | /// </summary>
|
| | | [UnityEditor.MenuItem("Tools/重新生成所有配置类")]
|
| | | public static void RegenerateAllConfigClasses()
|
| | | {
|
| | | string fullDir = Path.Combine(Application.dataPath, "ResourcesOut/Config");
|
| | | if (!Directory.Exists(fullDir))
|
| | | {
|
| | | Debug.LogError($"[ConfigGen] 配置目录不存在: {fullDir}");
|
| | | return;
|
| | | }
|
| | |
|
| | | string[] txtFiles = Directory.GetFiles(fullDir, "*.txt", SearchOption.TopDirectoryOnly);
|
| | | int created = 0, skipped = 0;
|
| | | foreach (string f in txtFiles)
|
| | | {
|
| | | var fi = new FileInfo(f);
|
| | | int dot = fi.Name.IndexOf('.');
|
| | | if (dot <= 0) continue;
|
| | |
|
| | | string baseName = fi.Name.Substring(0, dot);
|
| | | if (ConfigGenerater.ExcludeClassList.Contains(baseName + "Config"))
|
| | | {
|
| | | skipped++;
|
| | | continue;
|
| | | }
|
| | |
|
| | | CreateConfigClass(fi);
|
| | | created++;
|
| | | }
|
| | |
|
| | | ConfigGenerater.Generate();
|
| | | AssetDatabase.Refresh();
|
| | | Debug.LogWarning($"[ConfigGen] 配置类重新生成完成: 生成 {created} 个, 跳过 {skipped} 个");
|
| | | }
|
| | |
|
| | | public static void CreateConfigClass(FileInfo fileInfo, bool isIL = false)
|
| | | {
|
| | | var lines = File.ReadAllLines(fileInfo.FullName);
|
| | |
| | | }
|
| | | else if (type.Contains("int[][]"))
|
| | | {
|
| | | return StringUtility.Concat(field, " = JsonMapper.ToObject<int[][]>(tables", "[", index.ToString(), "].Replace(\"(\", \"[\").Replace(\")\", \"]\")); ");
|
| | | return StringUtility.Concat(field, " = ConfigParse.ParseIntArray2(tables", "[", index.ToString(), "]); ");
|
| | | }
|
| | | else if (type.Contains("Dictionary<int, int>"))
|
| | | {
|
| | |
| | | }
|
| | | else if (type.Contains("float[][]"))
|
| | | {
|
| | | // float 二维数组全项目仅少量使用,手写版收益可忽略,保留 JsonMapper 确保与原先精度完全一致
|
| | | return StringUtility.Concat(field, " = JsonMapper.ToObject<float[][]>(tables", "[", index.ToString(), "].Replace(\"(\", \"[\").Replace(\")\", \"]\")); ");
|
| | | }
|
| | | else if (type.Contains("int[]"))
|
| | | {
|
| | | var line0 = StringUtility.Concat("if (tables", "[", index.ToString(), "].Contains(\"[\"))\n");
|
| | | var line0 = StringUtility.Concat("if (tables", "[", index.ToString(), "].IndexOf('[') >= 0)\n");
|
| | | var line0_1 = StringUtility.Concat(retract3, "{\n");
|
| | | var line0_2 = StringUtility.Concat(retract4, field, " = JsonMapper.ToObject<int[]>(tables", "[", index.ToString(), "]);\n");
|
| | | var line0_2 = StringUtility.Concat(retract4, field, " = ConfigParse.ParseIntArray(tables", "[", index.ToString(), "]);\n");
|
| | | var line0_3 = StringUtility.Concat(retract3, "}\n");
|
| | | var line0_4 = StringUtility.Concat(retract3, "else\n");
|
| | | var line0_5 = StringUtility.Concat(retract3, "{\n");
|
| | |
| | | var line2 = StringUtility.Concat(retract4, field, " = ", "new int", "[", field, "StringArray.Length]", ";", "\n");
|
| | | var line3 = StringUtility.Concat(retract4, "for (int i=0;i<", field, "StringArray", ".Length", ";", "i++", ")", "\n");
|
| | | var line4 = StringUtility.Concat(retract4, "{\n");
|
| | | var line5 = StringUtility.Concat(retract5, " int.TryParse(", field, "StringArray", "[i]", ",", "out ", field, "[i]", ")", ";", "\n");
|
| | | var line5 = StringUtility.Concat(retract5, " ", field, "[i]", " = ConfigParse.ParseInt(", field, "StringArray", "[i]", ")", ";", "\n");
|
| | | var line6 = StringUtility.Concat(retract4, "}\n");
|
| | | var line0_6 = StringUtility.Concat(retract3, "}");
|
| | |
|
| | |
| | | }
|
| | | else if (type.Contains("float[]"))
|
| | | {
|
| | | var line0 = StringUtility.Concat("if (tables", "[", index.ToString(), "].Contains(\"[\"))\n");
|
| | | var line0 = StringUtility.Concat("if (tables", "[", index.ToString(), "].IndexOf('[') >= 0)\n");
|
| | | var line0_1 = StringUtility.Concat(retract3, "{\n");
|
| | | var line0_2 = StringUtility.Concat(retract4, field, " = JsonMapper.ToObject<float[]>(tables", "[", index.ToString(), "]);\n");
|
| | | var line0_3 = StringUtility.Concat(retract3, "}\n");
|
| | |
| | | }
|
| | | else if (type.Contains("int"))
|
| | | {
|
| | | return StringUtility.Concat("int.TryParse(tables", "[", index.ToString(), "]", ",", "out ", field, ")", "; ");
|
| | | return StringUtility.Concat(field, " = ConfigParse.ParseInt(tables", "[", index.ToString(), "]", ")", "; ");
|
| | | }
|
| | | else if (type.Contains("long"))
|
| | | {
|
| | | return StringUtility.Concat("long.TryParse(tables", "[", index.ToString(), "]", ",", "out ", field, ")", "; ");
|
| | | return StringUtility.Concat(field, " = ConfigParse.ParseLong(tables", "[", index.ToString(), "]", ")", "; ");
|
| | | }
|
| | | else if (type.Contains("float"))
|
| | | {
|
| | | // 标量 float 保留 float.TryParse:手写版收益有限,且存在精度与原先不一致的风险
|
| | | return StringUtility.Concat("float.TryParse(tables", "[", index.ToString(), "]", ",", "out ", field, ")", "; ");
|
| | | }
|
| | | else if (type.Contains("string"))
|
| | |
| | | else if (type.Contains("bool"))
|
| | | {
|
| | | var line1 = StringUtility.Concat("var ", field, "Temp", " = 0", ";", "\n");
|
| | | var line2 = StringUtility.Concat(retract3, "int.TryParse(tables", "[", index.ToString(), "]", ",", "out ", field, "Temp", ")", "; ", "\n");
|
| | | var line2 = StringUtility.Concat(retract3, field, "Temp = ConfigParse.ParseInt(tables", "[", index.ToString(), "]", ")", "; ", "\n");
|
| | | var line3 = StringUtility.Concat(retract3, field, "=", field, "Temp", "!=0", ";");
|
| | | return StringUtility.Concat(line1, line2, line3);
|
| | | }
|
| | |
| | | text = Regex.Replace(text, "#FileName#", fileNameWithoutExtension.Substring(0, fileNameWithoutExtension.Length - 6));
|
| | | text = Regex.Replace(text, "#KEY#", _idType);
|
| | |
|
| | | // 主键解析:int 键直接手写解析,绕开 GetKey 的 (U)(object) 装箱;
|
| | | // string 键是引用转换,无装箱,直接返回;其余类型保持原 GetKey 路径。
|
| | | string loadKeyExpr;
|
| | | if (_idType == "int") loadKeyExpr = "ConfigParse.ParseInt(_key)";
|
| | | else if (_idType == "string") loadKeyExpr = "_key";
|
| | | else loadKeyExpr = "GetKey(_key)";
|
| | | text = Regex.Replace(text, "#LoadKeyExpr#", loadKeyExpr);
|
| | |
|
| | | bool encoderShouldEmitUTF8Identifier = true;
|
| | | bool throwOnInvalidBytes = false;
|
| | | UTF8Encoding encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier, throwOnInvalidBytes);
|
| | |
| | |
|
| | | public override #KEY# LoadKey(string _key)
|
| | | {
|
| | | #KEY# key = GetKey(_key);
|
| | | return key;
|
| | | return #LoadKeyExpr#;
|
| | | }
|
| | |
|
| | | public override void LoadConfig(string input)
|
| | |
| | | // 暂时无用的表
|
| | | "PlayerFacePicStarConfig",
|
| | | "PlayerFaceStarConfig",
|
| | | "DirtyWordConfig",
|
| | | };
|
| | |
|
| | | [MenuItem("Tools/手动刷新")]
|
| | |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid.<>c<AsyncLazy.<Run>d__8> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid.<>c<CheckAssetValidTask.<LoadConfigsViaYooAsset>d__4> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid.<>c<CyclicScroll.<Init>d__65<object>> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid.<>c<DirtyNameConfig.<DirtyNameInitAsync>d__17> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid.<>c<DirtyWordConfig.<DirtyWordInitAsync>d__18> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid.<>c<FunctionButton.<OnStateChange>d__65> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid.<>c<HeroCollectionCardCell.<DelayedCreateSpine>d__15> |
| | |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid<AsyncLazy.<Run>d__8> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid<CheckAssetValidTask.<LoadConfigsViaYooAsset>d__4> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid<CyclicScroll.<Init>d__65<object>> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid<DirtyNameConfig.<DirtyNameInitAsync>d__17> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid<DirtyWordConfig.<DirtyWordInitAsync>d__18> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid<FunctionButton.<OnStateChange>d__65> |
| | | // Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoid<HeroCollectionCardCell.<DelayedCreateSpine>d__15> |
| | |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.AwaitUnsafeOnCompleted<Cysharp.Threading.Tasks.UniTask.Awaiter<object>,StageManager.<ToLoginScene>d__6>(Cysharp.Threading.Tasks.UniTask.Awaiter<object>&,StageManager.<ToLoginScene>d__6&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.AwaitUnsafeOnCompleted<Cysharp.Threading.Tasks.UnityAsyncExtensions.AsyncOperationAwaiter,StageManager.<ReturnToLoginScene>d__7>(Cysharp.Threading.Tasks.UnityAsyncExtensions.AsyncOperationAwaiter&,StageManager.<ReturnToLoginScene>d__7&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.AwaitUnsafeOnCompleted<Cysharp.Threading.Tasks.YieldAwaitable.Awaiter,AssetVersionUtility.<BeginCheckAssetsAsync>d__30>(Cysharp.Threading.Tasks.YieldAwaitable.Awaiter&,AssetVersionUtility.<BeginCheckAssetsAsync>d__30&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.AwaitUnsafeOnCompleted<Cysharp.Threading.Tasks.YieldAwaitable.Awaiter,DirtyNameConfig.<DirtyNameInitAsync>d__17>(Cysharp.Threading.Tasks.YieldAwaitable.Awaiter&,DirtyNameConfig.<DirtyNameInitAsync>d__17&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.AwaitUnsafeOnCompleted<Cysharp.Threading.Tasks.YieldAwaitable.Awaiter,DirtyWordConfig.<DirtyWordInitAsync>d__18>(Cysharp.Threading.Tasks.YieldAwaitable.Awaiter&,DirtyWordConfig.<DirtyWordInitAsync>d__18&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.AwaitUnsafeOnCompleted<Cysharp.Threading.Tasks.YieldAwaitable.Awaiter,ServerListParser.<ParseCommonServerListAsync>d__5>(Cysharp.Threading.Tasks.YieldAwaitable.Awaiter&,ServerListParser.<ParseCommonServerListAsync>d__5&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.AwaitUnsafeOnCompleted<Cysharp.Threading.Tasks.YieldAwaitable.Awaiter,ServerListParser.<ParsePlayerServerListAsync>d__7>(Cysharp.Threading.Tasks.YieldAwaitable.Awaiter&,ServerListParser.<ParsePlayerServerListAsync>d__7&) |
| | |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.Start<CyclicScroll.<Init>d__65<ServerDataCouple>>(CyclicScroll.<Init>d__65<ServerDataCouple>&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.Start<CyclicScroll.<Init>d__65<int>>(CyclicScroll.<Init>d__65<int>&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.Start<CyclicScroll.<Init>d__65<object>>(CyclicScroll.<Init>d__65<object>&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.Start<DirtyNameConfig.<DirtyNameInitAsync>d__17>(DirtyNameConfig.<DirtyNameInitAsync>d__17&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.Start<DirtyWordConfig.<DirtyWordInitAsync>d__18>(DirtyWordConfig.<DirtyWordInitAsync>d__18&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.Start<DynamicCyclicScroll.<Init>d__1<object>>(DynamicCyclicScroll.<Init>d__1<object>&) |
| | | // System.Void Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder.Start<FunctionButton.<OnStateChange>d__65>(FunctionButton.<OnStateChange>d__65&) |
| | |
| | | DailyQuestConfig |
| | | DailyQuestOpenTimeConfig |
| | | DienstgradConfig |
| | | DirtyNameConfig |
| | | EffectConfig |
| | | EmojiPackConfig |
| | | EquipPlaceMapConfig |