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 ++++++--
Assets/Launch/Manager/ResManager.cs | 2 +-
2 files changed, 7 insertions(+), 3 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)");
diff --git a/Assets/Launch/Manager/ResManager.cs b/Assets/Launch/Manager/ResManager.cs
index 18a7d81..5138cbd 100644
--- a/Assets/Launch/Manager/ResManager.cs
+++ b/Assets/Launch/Manager/ResManager.cs
@@ -161,7 +161,7 @@
}
else if (tp == typeof(TextAsset))
{
- path += ".txt";
+ path += "txt";
}
Debug.Log($"[ResManager] 缂栬緫鍣ㄥ姞杞借矾寰�: {path}");
retAsset = AssetDatabase.LoadAssetAtPath<T>(path);
--
Gitblit v1.8.0