From 0fa617a09eedf6bdb25eda55fac1d3344859fd93 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期二, 31 三月 2026 19:46:31 +0800
Subject: [PATCH] webgl
---
Main/Manager/UIManager.cs | 131 +++----------------------------------------
1 files changed, 10 insertions(+), 121 deletions(-)
diff --git a/Main/Manager/UIManager.cs b/Main/Manager/UIManager.cs
index 4ae6aeb..12a2402 100644
--- a/Main/Manager/UIManager.cs
+++ b/Main/Manager/UIManager.cs
@@ -775,6 +775,16 @@
/// </summary>
public async UniTask<T> OpenWindowAsync<T>(int functionOrder = 0) where T : UIBase
{
+ if (typeof(T).Name == "MainWin")
+ {
+ //MainWin 姣旇緝鍏抽敭涓斿敮涓�锛屽仛瀹夊叏闃茶寖
+ var ui = GetUI<MainWin>();
+ if (ui != null)
+ {
+ ui.ClickFunc(0);
+ return ui as T;
+ }
+ }
string uiName = typeof(T).Name;
var result = await OpenWindowAsync(uiName, functionOrder);
return result as T;
@@ -976,127 +986,6 @@
return null;
}
- public async UniTask<UIBase> OpenWindow(string uiName, int functionOrder = 0)
- {
- // 浼樺厛浠巆losedUIDict涓幏鍙�
- UIBase parentUI = null;
-
- UIBase returnValue = null;
-
- List<UIBase> closedUIList = new List<UIBase>();
-
- if (closedUIDict.TryGetValue(uiName, out closedUIList) && closedUIList.Count > 0)
- {
- #if UNITY_EDITOR
- Debug.Log("OpenWindow getFromClosedDict " + uiName);
- #endif
-
- returnValue = closedUIList[0] as UIBase;
- closedUIList.RemoveAt(0);
-
- if (closedUIList.Count == 0)
- {
- closedUIDict.Remove(uiName);
- }
- }
- else
- {
- #if UNITY_EDITOR
- Debug.Log("OpenWindow getNewLoad " + uiName);
- #endif
- returnValue = await LoadUIResourceAsync(uiName);
- if (returnValue == null)
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError($"鎵撳紑UI澶辫触: {uiName}");
- return null;
- }
- }
-
- returnValue.gameObject.SetActive(true);
-
- // 鑷姩璁剧疆鐖剁骇UI, 濡傛灉鍕鹃�変簡ismainui 鍒欎笉闇�瑕佹壘鐖剁骇UI
- if (returnValue.supportParentChildRelation && uiStack.Count > 0 && !returnValue.isMainUI)
- {
- // 鑾峰彇鏍堥《UI
- parentUI = GetLastSupportParentChildRelationUI();
- }
-
- // 璁剧疆鐖剁骇UI
- if (parentUI != null)
- {
- // 璁剧疆鐖跺瓙鍏崇郴
- returnValue.parentUI = parentUI;
- if (parentUI.childrenUI == null)
- {
- // 鍒濆鍖栫埗绾I鐨勫瓙UI鍒楄〃
- parentUI.childrenUI = new List<UIBase>();
- }
- // 娣诲姞鍒扮埗绾I鐨勫瓙UI鍒楄〃
- parentUI.childrenUI.Add(returnValue);
- }
-
- // 鏇存柊鍥炲悎鏁�
- currentRound++;
- // 璁剧疆UI鐨勬渶鍚庝娇鐢ㄥ洖鍚堟暟
- returnValue.lastUsedRound = currentRound;
- // 鏇存柊鐖剁骇UI鐨勫洖鍚堟暟
- UpdateParentUIRounds(returnValue);
-
- // 灏哢I娣诲姞鍒板瓧鍏镐腑
- if (!uiDict.ContainsKey(uiName))
- {
- // 濡傛灉瀛楀吀涓笉瀛樺湪璇ョ被鍨嬬殑UI锛屽垱寤烘柊鍒楄〃
- uiDict[uiName] = new List<UIBase>();
- }
- // 娣诲姞鍒癠I鍒楄〃
- uiDict[uiName].Add(returnValue);
-
-#if UNITY_EDITOR
- if (uiDict[uiName].Count > 5)
- {
- Debug.LogError("宸叉墦寮�" + uiDict[uiName].Count + "涓晫闈�:" + uiName);
- }
-#endif
-
- // 灏哢I娣诲姞鍒版爤涓�
- uiStack.Push(returnValue);
-
- // 鏇存柊UI鎺掑簭椤哄簭
- UpdateUISortingOrder();
-
- // 鎵撳紑UI
- returnValue.functionOrder = functionOrder;
- returnValue.HandleOpen();
-
- OnOpenWindow?.Invoke(returnValue);
-
- // 妫�鏌ュ苟鍏抽棴闀挎椂闂存湭浣跨敤鐨刄I
- CheckAndCloseIdleUI();
-
- return returnValue;
- }
-
- /// <summary>
- /// 鎵撳紑UI
- /// </summary>
- public T OpenWindow<T>(int functionOrder = 0) where T : UIBase
- {
- if (typeof(T).Name == "MainWin")
- {
- //MainWin 姣旇緝鍏抽敭涓斿敮涓�锛屽仛瀹夊叏闃茶寖
- var ui = GetUI<MainWin>();
- if (ui != null)
- {
- ui.ClickFunc(0);
- return ui as T;
- }
- }
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
- return OpenWindow(uiName, functionOrder) as T;
- }
-
/// <summary>
/// 鍏抽棴UI
/// </summary>
--
Gitblit v1.8.0