From 5ed6b8c3783cae02f057e7e43570b3863acb73be Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Wed, 19 Jul 2023 17:33:41 +0800 Subject: [PATCH] Update UIModule.cs --- .../Runtime/GameFramework/UI/UIModule.cs | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIModule.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIModule.cs index 8ecb0665..4057c2d2 100644 --- a/Assets/TEngine/Runtime/GameFramework/UI/UIModule.cs +++ b/Assets/TEngine/Runtime/GameFramework/UI/UIModule.cs @@ -162,7 +162,7 @@ namespace TEngine return string.Empty; } - UIWindow topWindow = _stack[_stack.Count - 1]; + UIWindow topWindow = _stack[^1]; return topWindow.WindowName; } @@ -321,6 +321,40 @@ namespace TEngine _stack.Clear(); } + + /// + /// 关闭所有窗口除了。 + /// + public void CloseAllWithOut(UIWindow withOut) + { + for (int i = _stack.Count-1; i>=0; i--) + { + UIWindow window = _stack[i]; + if (window == withOut) + { + continue; + } + window.InternalDestroy(); + _stack.RemoveAt(i); + } + } + + /// + /// 关闭所有窗口除了。 + /// + public void CloseAllWithOut() where T:UIWindow + { + for (int i = _stack.Count-1; i>=0; i--) + { + UIWindow window = _stack[i]; + if (window.GetType() == typeof(T)) + { + continue; + } + window.InternalDestroy(); + _stack.RemoveAt(i); + } + } private void OnWindowPrepare(UIWindow window) { @@ -374,7 +408,7 @@ namespace TEngine if (attribute == null) throw new Exception($"Window {type.FullName} not found {nameof(WindowAttribute)} attribute."); - string assetName = string.IsNullOrEmpty(attribute.AssetName) ? type.Name : attribute.AssetName; + string assetName = string.IsNullOrEmpty(attribute.Location) ? type.Name : attribute.Location; window.Init(type.FullName, attribute.WindowLayer, attribute.FullScreen, assetName); return window; }