From a48ae9384860a71264b88bfa4810c896270e9e0a Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 08 五月 2025 08:53:59 +0800
Subject: [PATCH] config loading

---
 Main/Config/ConfigBase.cs     |    2 +-
 Main/Manager/StageManager.cs  |    2 +-
 Main/Manager/ConfigManager.cs |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/Main/Config/ConfigBase.cs b/Main/Config/ConfigBase.cs
index 3e371da..ea87401 100644
--- a/Main/Config/ConfigBase.cs
+++ b/Main/Config/ConfigBase.cs
@@ -134,7 +134,7 @@
         }
         else
         {
-            Debug.LogError("GetKey 绫诲瀷閿欒");
+            Debug.LogError("GetKey 鎰忓鐨刱ey绫诲瀷 绫诲瀷閿欒 " + typeof(U).Name);
             return default(U);
         }
     }
diff --git a/Main/Manager/ConfigManager.cs b/Main/Manager/ConfigManager.cs
index 4af4662..51ea8a3 100644
--- a/Main/Manager/ConfigManager.cs
+++ b/Main/Manager/ConfigManager.cs
@@ -13,6 +13,14 @@
         private set;
     }
 
+    private float loadingProgress = 0f;
+
+    public override void Init()
+    {
+        base.Init();
+        InitConfigs();
+    }
+
     public virtual async UniTask InitConfigs()
     {
         // 鍔犺浇閰嶇疆鏂囦欢
@@ -21,13 +29,46 @@
 
     protected async UniTask LoadConfigs()
     {
+        loadingProgress = 0f;
         isLoadFinished = false;
 
         // 鍔犺浇閰嶇疆鏂囦欢
 
         // 鍔犺浇瀹屾垚鍚庤缃甶sLoadFinished涓簍rue
+        loadingProgress = 1f;
         isLoadFinished = true;
     }
+
+    private async UniTask LoadConfigByType(Type configType)
+    {
+        string configName = configType.Name;
+        TextAsset textAsset = await ResManager.Instance.LoadAsset<TextAsset>("Config", configName);
+        if (textAsset != null)
+        {
+            string[] lines = textAsset.text.Split('\n');
+            var methodInfo = configType.GetMethod("Init", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
+            if (methodInfo != null)
+            {
+                methodInfo.Invoke(null, new object[] { lines });
+                // 璁剧疆鍒濆鍖栨爣蹇�
+                var isInitField = configType.GetField("isInit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
+                if (isInitField != null)
+                {
+                    isInitField.SetValue(null, true);
+                }
+                Debug.Log($"鍔犺浇閰嶇疆: {configType.Name} 鎴愬姛");
+            }
+            else
+            {
+                Debug.LogError($"閰嶇疆绫� {configType.Name} 娌℃湁闈欐�両nit鏂规硶");
+            }
+        }
+        else
+        {
+            Debug.LogError($"鎵句笉鍒伴厤缃枃浠�: {configName}");
+        }
+    }
+
 
 
 
@@ -64,6 +105,11 @@
         }
     }
 
+    public float GetLoadingProgress()
+    {
+        return loadingProgress;
+    }
+
     private void ClearConfigDictionary<T>() where T : class
     {
         // 閲嶇疆 T 鍒濆鍖栫姸鎬�
@@ -76,9 +122,11 @@
 
     public override void Release()
     {
+        // 娌℃湁鎵惧埌閰嶇疆绫�
     }
 
 
 
 
+
 }
\ No newline at end of file
diff --git a/Main/Manager/StageManager.cs b/Main/Manager/StageManager.cs
index 55bfdc8..c1c72ee 100644
--- a/Main/Manager/StageManager.cs
+++ b/Main/Manager/StageManager.cs
@@ -29,7 +29,7 @@
 
         AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Login");
 
-        await OnLoading(asyncOperation, () => 1f);
+        await OnLoading(asyncOperation, ConfigManager.Instance.GetLoadingProgress);
 
         Main.OnSwitchToLoginScene();
 

--
Gitblit v1.8.0