From 1ab047b5fdd933c38ba0519ec2e83a44512ea8d7 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 26 三月 2026 17:46:11 +0800
Subject: [PATCH] webgl代码合并 1

---
 Main/System/ClientVersion/VersionConfig.cs |   75 +++++++++++++++++++++++++++++--------
 1 files changed, 59 insertions(+), 16 deletions(-)

diff --git a/Main/System/ClientVersion/VersionConfig.cs b/Main/System/ClientVersion/VersionConfig.cs
index 5a0251f..c9f8c69 100644
--- a/Main/System/ClientVersion/VersionConfig.cs
+++ b/Main/System/ClientVersion/VersionConfig.cs
@@ -3,6 +3,8 @@
 using UnityEngine;
 using System.IO;
 using LitJson;
+using Cysharp.Threading.Tasks;
+
 
 #if UNITY_EDITOR
 using UnityEditor;
@@ -12,6 +14,7 @@
 
 public class VersionConfig : ScriptableObject
 {
+
     public const string VERSION_ALTERNATIVE = "1.0.0";
 
     [SerializeField] public string m_AppId = string.Empty;
@@ -73,15 +76,7 @@
         {
             if (string.IsNullOrEmpty(m_GameId))
             {
-                var gameText = Resources.Load<TextAsset>("Game");
-                if (gameText != null)
-                {
-                    m_GameId = gameText.text;
-                }
-                else
-                {
-                    m_GameId = "xssg";
-                }
+                Debug.LogError("VersionConfig gameId is empty, do getasync first");
             }
 
             return m_GameId;
@@ -200,14 +195,13 @@
         }
     }
 
-    static VersionConfig config = null;
-    public static VersionConfig Get()
+    public static async UniTask<VersionConfig> GetAsync()
     {
         if (config == null)
         {
             if (Application.isEditor)
             {
-                config = Resources.Load<VersionConfig>("VersionConfig");
+                config = await Resources.LoadAsync<VersionConfig>("VersionConfig") as VersionConfig;
                 //debug鐧诲綍鍚庣浜屾鍚姩榛樿鎭㈠test
                 if (LocalSave.GetBool("RestoreTest"))
                 {
@@ -215,23 +209,72 @@
                     LocalSave.SetBool("RestoreTest", false);
                     Debug.Log("appid 鎭㈠test");
                 }
-
             }
             else
             {
-                var text = Resources.Load<TextAsset>("VersionConfigEx");
-                if (text != null)
+                var textAsset = await Resources.LoadAsync<TextAsset>("VersionConfigEx") as TextAsset;
+                if (textAsset != null)
                 {
                     config = ScriptableObject.CreateInstance<VersionConfig>();
-                    var json = JsonMapper.ToObject(text.text);
+                    var json = JsonMapper.ToObject(textAsset.text);
                     ReadJson(json);  //閫愪竴瑙f瀽锛屼笉鐢╒ersionConfig绫荤粨鏋勮鍙栵紝鍥犱负鍙橀噺瀹氫箟鏄寜asset鐨勭粨鏋勫畾涔夌殑
                 }
+                else
+                {
+                    Debug.LogError("[VersionConfig] VersionConfigEx not found, falling back to VersionConfig asset");
+                    config = await Resources.LoadAsync<VersionConfig>("VersionConfig") as VersionConfig;
+                }
+            }
+        }
+
+        if (string.IsNullOrEmpty(config.m_GameId))
+        {
+            var gameText = await Resources.LoadAsync<TextAsset>("Game") as TextAsset;
+            if (gameText != null)
+            {
+                config.m_GameId = gameText.text;
+            }
+            else
+            {
+                config.m_GameId = "xssg";
             }
         }
 
         return config;
     }
 
+    public static VersionConfig config = null;
+    // public static VersionConfig Get()
+    // {
+    //     if (config == null)
+    //     {
+    //         if (Application.isEditor)
+    //         {
+    //             config = Resources.Load<VersionConfig>("VersionConfig");
+    //             //debug鐧诲綍鍚庣浜屾鍚姩榛樿鎭㈠test
+    //             if (LocalSave.GetBool("RestoreTest"))
+    //             {
+    //                 config.m_AppId = "test";
+    //                 LocalSave.SetBool("RestoreTest", false);
+    //                 Debug.Log("appid 鎭㈠test");
+    //             }
+
+    //         }
+    //         else
+    //         {
+    //             var text = Resources.Load<TextAsset>("VersionConfigEx");
+    //             if (text != null)
+    //             {
+    //                 config = ScriptableObject.CreateInstance<VersionConfig>();
+    //                 var json = JsonMapper.ToObject(text.text);
+    //                 ReadJson(json);  //閫愪竴瑙f瀽锛屼笉鐢╒ersionConfig绫荤粨鏋勮鍙栵紝鍥犱负鍙橀噺瀹氫箟鏄寜asset鐨勭粨鏋勫畾涔夌殑
+    //             }
+    //         }
+    //     }
+
+    //     return config;
+    // }
+
     public static void ReadJson(JsonData _data)
     {
         try

--
Gitblit v1.8.0