From bc1cb6da854cb2e9144f10ed55330a537ecdca16 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 04 三月 2026 14:35:57 +0800
Subject: [PATCH] 466 h5版本 资源规则修改 打包修改(未完成 勿拉取)
---
Main/Manager/UIManager.cs | 127 +++++++++++++++++++----------------------
1 files changed, 59 insertions(+), 68 deletions(-)
diff --git a/Main/Manager/UIManager.cs b/Main/Manager/UIManager.cs
index b589778..35baaf0 100644
--- a/Main/Manager/UIManager.cs
+++ b/Main/Manager/UIManager.cs
@@ -75,27 +75,21 @@
/// <summary>
/// 鍒濆鍖朥I绠$悊鍣�
/// </summary>
- public override void Init()
+ public override async UniTask Init()
{
- base.Init();
-
- // 鍒濆鍖朥I鏍硅妭鐐�
- InitUIRoot();
-
+ await InitUIRoot();
// 鍒濆鍖栫紦瀛�
layerSortingOrderCache.Clear();
layerTransformCache.Clear();
uiInstanceCounter.Clear();
-
DOTween.SetTweensCapacity(500, 50);
Debug.Log("UI绠$悊鍣ㄥ垵濮嬪寲瀹屾垚");
-
}
/// <summary>
/// 鍒濆鍖朥I鏍硅妭鐐�
/// </summary>
- private void InitUIRoot()
+ private async UniTask InitUIRoot()
{
// 鏌ユ壘UI鏍硅妭鐐�
GameObject root = GameObject.Find("UIRoot");
@@ -103,15 +97,14 @@
// 濡傛灉鍦烘櫙涓病鏈塙I鏍硅妭鐐癸紝鍒欏垱寤轰竴涓�
if (root == null)
{
- root = GameObject.Instantiate(BuiltInLoader.LoadPrefab("UIRoot"));
+ var prefab = await BuiltInLoader.LoadPrefabAsync("UIRoot");
+ root = GameObject.Instantiate(prefab);
root.name = "UIRoot";
if (root == null)
{
Debug.LogError("鏃犳硶鎵惧埌UI鏍硅妭鐐�");
return;
}
-
- // 娣诲姞DontDestroyOnLoad缁勪欢锛岀‘淇漊I鏍硅妭鐐瑰湪鍦烘櫙鍒囨崲鏃朵笉琚攢姣�
GameObject.DontDestroyOnLoad(root);
}
@@ -552,73 +545,71 @@
#region UI璧勬簮绠$悊
- private UIBase LoadUIResource(string uiName)
- {
+ // private UIBase LoadUIResource(string uiName)
+ // {
- // 浠庤祫婧愮鐞嗗櫒鍔犺浇UI棰勫埗浣�
- GameObject prefab;
- if (uiName == "LaunchWin" || uiName == "DownLoadWin" || uiName == "RequestSecretWin" || uiName == "GameAgeWarnWin")
- {
- prefab = BuiltInLoader.LoadPrefab(uiName);
- }
- else
- {
- #pragma warning disable CS0618 // Obsolete 鈥� sync legacy fallback, use LoadUIResourceAsync
- prefab = ResManager.Instance.LoadAsset<GameObject>("UI", uiName);
- #pragma warning restore CS0618
- }
+ // // 浠庤祫婧愮鐞嗗櫒鍔犺浇UI棰勫埗浣�
+ // GameObject prefab;
+ // if (uiName == "LaunchWin" || uiName == "DownLoadWin" || uiName == "RequestSecretWin" || uiName == "GameAgeWarnWin")
+ // {
+ // prefab = await BuiltInLoader.LoadPrefabAsync(uiName);
+ // }
+ // else
+ // {
+ // prefab = await ResManager.Instance.LoadAssetAsync<GameObject>("UI", uiName);
+ // }
- // 妫�鏌ラ鍒朵綋鏄惁鍔犺浇鎴愬姛
- if (prefab == null)
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError($"鍔犺浇UI棰勫埗浣撳け璐�: {uiName}");
- return null;
- }
+ // // 妫�鏌ラ鍒朵綋鏄惁鍔犺浇鎴愬姛
+ // if (prefab == null)
+ // {
+ // // 璁板綍閿欒鏃ュ織
+ // Debug.LogError($"鍔犺浇UI棰勫埗浣撳け璐�: {uiName}");
+ // return null;
+ // }
- // 瀹炰緥鍖朥I瀵硅薄
- GameObject uiObject = GameObject.Instantiate(prefab);
- // 璁剧疆瀵硅薄鍚嶇О
- uiObject.name = uiName;
+ // // 瀹炰緥鍖朥I瀵硅薄
+ // GameObject uiObject = GameObject.Instantiate(prefab);
+ // // 璁剧疆瀵硅薄鍚嶇О
+ // uiObject.name = uiName;
- // 閫氳繃uiName鏄犲皠Type
- Type uiType = Type.GetType(uiName);
- if (uiType == null)
- {
- Debug.LogError($"鎵句笉鍒癠I绫诲瀷: {uiName}");
- return null;
- }
+ // // 閫氳繃uiName鏄犲皠Type
+ // Type uiType = Type.GetType(uiName);
+ // if (uiType == null)
+ // {
+ // Debug.LogError($"鎵句笉鍒癠I绫诲瀷: {uiName}");
+ // return null;
+ // }
- // 鑾峰彇UI鍩虹被缁勪欢
- UIBase uiBase = uiObject.GetComponent(uiType) as UIBase;
+ // // 鑾峰彇UI鍩虹被缁勪欢
+ // UIBase uiBase = uiObject.GetComponent(uiType) as UIBase;
- // 妫�鏌I鍩虹被缁勪欢鏄惁瀛樺湪
- if (uiBase == null)
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError($"UI棰勫埗浣� {uiName} 娌℃湁 UIBase 缁勪欢鎴栫被鍨嬩笉鍖归厤");
- return null;
- }
+ // // 妫�鏌I鍩虹被缁勪欢鏄惁瀛樺湪
+ // if (uiBase == null)
+ // {
+ // // 璁板綍閿欒鏃ュ織
+ // Debug.LogError($"UI棰勫埗浣� {uiName} 娌℃湁 UIBase 缁勪欢鎴栫被鍨嬩笉鍖归厤");
+ // return null;
+ // }
- // 璁剧疆UI鍚嶇О
- uiBase.uiName = uiName;
+ // // 璁剧疆UI鍚嶇О
+ // uiBase.uiName = uiName;
- // 璁剧疆鐖惰妭鐐逛负UI鏍硅妭鐐�
- Transform parentTrans = GetTransForLayer(uiBase.uiLayer);
+ // // 璁剧疆鐖惰妭鐐逛负UI鏍硅妭鐐�
+ // Transform parentTrans = GetTransForLayer(uiBase.uiLayer);
- uiObject.transform.SetParent(parentTrans, false);
+ // uiObject.transform.SetParent(parentTrans, false);
- // 璁剧疆鎺掑簭椤哄簭
- int baseSortingOrder = GetBaseSortingOrderForLayer(uiBase.uiLayer);
- uiBase.SetSortingOrder(baseSortingOrder);
+ // // 璁剧疆鎺掑簭椤哄簭
+ // int baseSortingOrder = GetBaseSortingOrderForLayer(uiBase.uiLayer);
+ // uiBase.SetSortingOrder(baseSortingOrder);
- return uiBase;
- }
+ // return uiBase;
+ // }
// 鍔犺浇UI棰勫埗浣�
- private T LoadUIResource<T>(string uiName) where T : UIBase
+ private async UniTask<T> LoadUIResource<T>(string uiName) where T : UIBase
{
- return LoadUIResource(uiName) as T;
+ return await LoadUIResourceAsync(uiName) as T;
}
// ====================================================================
@@ -633,7 +624,7 @@
GameObject root = GameObject.Find("UIRoot");
if (root == null)
{
- var prefab = await BuiltInLoader.LoadPrefabAsync("UIRoot");
+ var prefab = await BuiltInLoader.LoadPrefabAsync("UIRoot"); // 宸插紓姝ワ紝鏃犻渶淇敼
root = GameObject.Instantiate(prefab);
root.name = "UIRoot";
if (root == null)
@@ -927,7 +918,7 @@
return null;
}
- public UIBase OpenWindow(string uiName, int functionOrder = 0)
+ public async UniTask<UIBase> OpenWindow(string uiName, int functionOrder = 0)
{
// 浼樺厛浠巆losedUIDict涓幏鍙�
UIBase parentUI = null;
@@ -955,7 +946,7 @@
#if UNITY_EDITOR
Debug.Log("OpenWindow getNewLoad " + uiName);
#endif
- returnValue = LoadUIResource(uiName);
+ returnValue = await LoadUIResourceAsync(uiName);
if (returnValue == null)
{
// 璁板綍閿欒鏃ュ織
--
Gitblit v1.8.0