From 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 11 五月 2026 16:20:37 +0800
Subject: [PATCH] Merge branch 'master' into h5version
---
Main/System/ClientVersion/VersionConfig.cs | 49 +++++++++++++++++++++++++++++++++----------------
1 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/Main/System/ClientVersion/VersionConfig.cs b/Main/System/ClientVersion/VersionConfig.cs
index 5a0251f..d4d949a 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,20 +209,43 @@
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()
+ {
return config;
}
--
Gitblit v1.8.0