| | |
| | | // 自动生成:收集所有配置类型
|
| | | // 自动生成:收集所有配置类型
|
| | | HashSet<Type> configTypes = new HashSet<Type>() {
|
| | | typeof(ActBillboardAwardConfig),
|
| | | typeof(ActHeroAppearArtConfig),
|
| | | typeof(ActHeroAppearConfig),
|
| | | typeof(ActHeroAppearSkinArtConfig),
|
| | | typeof(ActHeroAppearStarConfig),
|
| | | typeof(ActLunhuidianTypeConfig),
|
| | | typeof(ActSignAwardConfig),
|
| | | typeof(ADAwardConfig),
|
| | | typeof(AppointItemConfig),
|
| | | typeof(AudioConfig),
|
| | |
| | | typeof(HeroQualityBreakConfig),
|
| | | typeof(HeroQualityConfig),
|
| | | typeof(HeroQualityLVConfig),
|
| | | typeof(HeroSkinAttrConfig),
|
| | | typeof(HeroSkinConfig),
|
| | | typeof(HeroTalentConfig),
|
| | | typeof(HorseClassConfig),
|
| | |
| | | typeof(PlayerFacePicConfig),
|
| | | typeof(PlayerLVConfig),
|
| | | typeof(PlayerPropertyConfig),
|
| | | typeof(PopWinOrderConfig),
|
| | | typeof(PresetUnlockConfig),
|
| | | typeof(PriorBundleConfig),
|
| | | typeof(RandomNameConfig),
|
| | |
| | |
|
| | | public override void Release()
|
| | | {
|
| | | // 清空 ActBillboardAwardConfig 字典
|
| | | ClearConfigDictionary<ActBillboardAwardConfig>();
|
| | | // 清空 ActHeroAppearArtConfig 字典
|
| | | ClearConfigDictionary<ActHeroAppearArtConfig>();
|
| | | // 清空 ActHeroAppearConfig 字典
|
| | | ClearConfigDictionary<ActHeroAppearConfig>();
|
| | | // 清空 ActHeroAppearSkinArtConfig 字典
|
| | | ClearConfigDictionary<ActHeroAppearSkinArtConfig>();
|
| | | // 清空 ActHeroAppearStarConfig 字典
|
| | | ClearConfigDictionary<ActHeroAppearStarConfig>();
|
| | | // 清空 ActLunhuidianTypeConfig 字典
|
| | | ClearConfigDictionary<ActLunhuidianTypeConfig>();
|
| | | // 清空 ActSignAwardConfig 字典
|
| | | ClearConfigDictionary<ActSignAwardConfig>();
|
| | | // 清空 ADAwardConfig 字典
|
| | | ClearConfigDictionary<ADAwardConfig>();
|
| | | // 清空 BattleMapConfig 字典
|
| | |
| | | ClearConfigDictionary<HeroLineupHaloConfig>();
|
| | | // 清空 HeroQualityLVConfig 字典
|
| | | ClearConfigDictionary<HeroQualityLVConfig>();
|
| | | // 清空 HeroSkinAttrConfig 字典
|
| | | ClearConfigDictionary<HeroSkinAttrConfig>();
|
| | | // 清空 HorseClassConfig 字典
|
| | | ClearConfigDictionary<HorseClassConfig>();
|
| | | // 清空 HorseSkinConfig 字典
|
| | |
| | | ClearConfigDictionary<PlayerAttrConfig>();
|
| | | // 清空 PlayerFaceConfig 字典
|
| | | ClearConfigDictionary<PlayerFaceConfig>();
|
| | | // 清空 PopWinOrderConfig 字典
|
| | | ClearConfigDictionary<PopWinOrderConfig>();
|
| | | // 清空 PresetUnlockConfig 字典
|
| | | ClearConfigDictionary<PresetUnlockConfig>();
|
| | | // 清空 PriorBundleConfig 字典
|
| | |
| | | /// </summary>
|
| | | private async UniTask<string[]> LoadConfigTextAsync(Type configType)
|
| | | {
|
| | | <<<<<<< HEAD
|
| | | string configName = configType.Name;
|
| | | if (configName.EndsWith("Config"))
|
| | | configName = configName.Substring(0, configName.Length - 6);
|
| | | return await ResManager.Instance.LoadConfigAsync(configName);
|
| | | =======
|
| | | // 获取 Editor Assembly
|
| | | var editorAsm = System.AppDomain.CurrentDomain.GetAssemblies()
|
| | | .FirstOrDefault(a => a.FullName.Contains("Editor"));
|
| | |
|
| | | if (editorAsm == null)
|
| | | {
|
| | | Debug.LogError("[自检] 未找到 Editor Assembly,无法自检。");
|
| | | return;
|
| | | }
|
| | |
|
| | | // 反射获取 ConfigGenerater 类型
|
| | | var configGeneraterType = editorAsm.GetType("ConfigGenerater");
|
| | | if (configGeneraterType == null)
|
| | | {
|
| | | Debug.LogError("[自检] 未找到 ConfigGenerater 类型。");
|
| | | return;
|
| | | }
|
| | |
|
| | | // 调用 GetAllConfigClasses 静态方法
|
| | | var getAllConfigClassesMethod = configGeneraterType.GetMethod("GetAllConfigClasses", BindingFlags.Public | BindingFlags.Static);
|
| | | var allConfigClasses = getAllConfigClassesMethod?.Invoke(null, null) as List<string>;
|
| | | if (allConfigClasses == null)
|
| | | {
|
| | | Debug.LogError("[自检] 获取全部配置类失败。");
|
| | | return;
|
| | | }
|
| | |
|
| | | // 获取 ExcludeClassList 字段
|
| | | var excludeField = configGeneraterType.GetField("ExcludeClassList", BindingFlags.Public | BindingFlags.Static);
|
| | | var excludeClassList = excludeField?.GetValue(null) as List<string> ?? new List<string>();
|
| | |
|
| | | // 排除不需要的类
|
| | | var checkClasses = allConfigClasses.Where(c => !excludeClassList.Contains(c)).ToList();
|
| | |
|
| | | List<string> fastName = new List<string>();
|
| | |
|
| | | foreach (var className in checkClasses)
|
| | | {
|
| | | // 这里也要用 Editor Assembly 获取类型
|
| | | var configType = editorAsm.GetType(className) ?? Type.GetType(className);
|
| | | if (configType == null)
|
| | | {
|
| | | Debug.LogWarning($"[自检] 未找到类型: {className}");
|
| | | continue;
|
| | | }
|
| | |
|
| | | var sw = System.Diagnostics.Stopwatch.StartNew();
|
| | |
|
| | | // 反射调用静态Init方法
|
| | | string configName = configType.Name;
|
| | | if (configName.EndsWith("Config"))
|
| | | configName = configName.Substring(0, configName.Length - 6);
|
| | |
|
| | | string[] texts = ResManager.Instance.LoadConfig(configName);
|
| | | if (texts != null)
|
| | | {
|
| | | string[] lines = texts;
|
| | | var methodInfo = configType.GetMethod("Init", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy);
|
| | | if (methodInfo != null)
|
| | | {
|
| | | methodInfo.Invoke(null, new object[] { lines });
|
| | | }
|
| | | }
|
| | |
|
| | | sw.Stop();
|
| | |
|
| | | if (sw.ElapsedMilliseconds >= 500)
|
| | | {
|
| | | Debug.LogError($"[自检] 加载配置 {configType.Name} 耗时较长: {sw.ElapsedMilliseconds} ms");
|
| | | }
|
| | | else if (sw.ElapsedMilliseconds <= 5)
|
| | | {
|
| | | fastName.Add(configType.Name);
|
| | | }
|
| | | Debug.Log($"[自检] 加载配置: {configType.Name} 用时: {sw.ElapsedMilliseconds} ms");
|
| | | }
|
| | |
|
| | | // 释放所有已加载的配置
|
| | | foreach (var className in checkClasses)
|
| | | {
|
| | | var configType = editorAsm.GetType(className) ?? Type.GetType(className);
|
| | | if (configType == null) continue;
|
| | | var methodInfo = configType.GetMethod("ForceRelease", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy);
|
| | | if (methodInfo != null)
|
| | | {
|
| | | methodInfo.Invoke(null, null);
|
| | | }
|
| | | }
|
| | |
|
| | | System.IO.File.WriteAllText(Application.dataPath + "/fastConfig.txt", string.Join("\n", fastName));
|
| | | Debug.Log($"[自检] fastConfig.txt 生成完毕,快速表有:{string.Join(", ", fastName)}");
|
| | | >>>>>>> origin/master
|
| | | }
|
| | |
|
| | | /// <summary>
|