78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
|
|
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using Cysharp.Threading.Tasks;
|
||
|
|
|
||
|
|
public partial class UIManager
|
||
|
|
{
|
||
|
|
private Stack<UIWindow> _uiWindowStack = new Stack<UIWindow>(8);
|
||
|
|
|
||
|
|
public void PushWindow(UIWindow window)
|
||
|
|
{
|
||
|
|
if (window)
|
||
|
|
{
|
||
|
|
_uiWindowStack.Push(window);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public UIWindow PopWindow()
|
||
|
|
{
|
||
|
|
if (_uiWindowStack.Count > 0)
|
||
|
|
{
|
||
|
|
return _uiWindowStack.Pop();
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public UIWindow PopWindow(string checkWindowName)
|
||
|
|
{
|
||
|
|
if (_uiWindowStack.Count > 0)
|
||
|
|
{
|
||
|
|
var window = _uiWindowStack.Peek();
|
||
|
|
if (string.IsNullOrEmpty(checkWindowName) || checkWindowName.Equals(window.WindowName))
|
||
|
|
{
|
||
|
|
return _uiWindowStack.Pop();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void ClearHideStack()
|
||
|
|
{
|
||
|
|
_uiWindowStack.Clear();
|
||
|
|
}
|
||
|
|
|
||
|
|
public static async UniTask<UIWindow> AnimSwitchWindow(UIWindow hideWindow, UIWindowCloseType closeType, string showWindowName, object data)
|
||
|
|
{
|
||
|
|
if (hideWindow != null)
|
||
|
|
{
|
||
|
|
await hideWindow.AnimHide();
|
||
|
|
}
|
||
|
|
|
||
|
|
var showWindow = await UIManager.Instance.OpenWindow(showWindowName, data);
|
||
|
|
|
||
|
|
await showWindow.AnimShow();
|
||
|
|
|
||
|
|
hideWindow.CloseWindow(closeType);
|
||
|
|
|
||
|
|
return showWindow;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static async UniTask<UIWindow> AnimSwitchWindow(UIWindow hideWindow, UIWindowCloseType closeType, UIWindow showWindow, object data)
|
||
|
|
{
|
||
|
|
if (hideWindow != null)
|
||
|
|
{
|
||
|
|
await hideWindow.AnimHide();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (showWindow != null)
|
||
|
|
{
|
||
|
|
showWindow.OpenWindow(data);
|
||
|
|
await showWindow.AnimShow();
|
||
|
|
}
|
||
|
|
|
||
|
|
hideWindow.CloseWindow(closeType);
|
||
|
|
|
||
|
|
return showWindow;
|
||
|
|
}
|
||
|
|
}
|