From 346ca3658a3a2c6c48a7ca2f11bdf03ee59ffc11 Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期二, 13 五月 2025 18:02:39 +0800 Subject: [PATCH] 配置跟资源的一些问题修改 --- Assets/Editor/ConfigGen/ConfigGenerater.cs | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Editor/ConfigGen/ConfigGenerater.cs b/Assets/Editor/ConfigGen/ConfigGenerater.cs index da2c382..0312a6e 100644 --- a/Assets/Editor/ConfigGen/ConfigGenerater.cs +++ b/Assets/Editor/ConfigGen/ConfigGenerater.cs @@ -194,11 +194,15 @@ sb.AppendLine(" private async UniTask LoadConfigByType(Type configType)"); sb.AppendLine(" {"); sb.AppendLine(" string configName = configType.Name;"); + sb.AppendLine(" if (configName.EndsWith(\"Config\"))"); + sb.AppendLine(" {"); + sb.AppendLine(" configName = configName.Substring(0, configName.Length - 6);"); + sb.AppendLine(" }"); sb.AppendLine(" TextAsset textAsset = await ResManager.Instance.LoadAsset<TextAsset>(\"Config\", configName);"); sb.AppendLine(" if (textAsset != null)"); sb.AppendLine(" {"); sb.AppendLine(" string[] lines = textAsset.text.Split('\\n');"); - sb.AppendLine(" var methodInfo = configType.GetMethod(\"Init\", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);"); + 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(" {"); sb.AppendLine(" methodInfo.Invoke(null, new object[] { lines });"); @@ -234,7 +238,7 @@ sb.AppendLine(" var methodInfo = typeof(T).GetMethod(\"Init\", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);"); sb.AppendLine(" if (methodInfo != null)"); sb.AppendLine(" {"); - sb.AppendLine(" methodInfo.Invoke(null, new object[] { lines });"); + sb.AppendLine(" methodInfo.Invoke(null, lines);"); sb.AppendLine(" // 璁剧疆鍒濆鍖栨爣蹇�"); sb.AppendLine(" var isInitField = typeof(T).GetField(\"isInit\", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);"); sb.AppendLine(" if (isInitField != null)"); -- Gitblit v1.8.0