diff --git a/GFramework.Game.Abstractions/ui/IUiRouter.cs b/GFramework.Game.Abstractions/ui/IUiRouter.cs index d257ff2..cc6c2e9 100644 --- a/GFramework.Game.Abstractions/ui/IUiRouter.cs +++ b/GFramework.Game.Abstractions/ui/IUiRouter.cs @@ -103,7 +103,7 @@ public interface IUiRouter : ISystem /// 获取当前栈顶的UI页面行为对象 /// /// 栈顶的IUiPageBehavior对象,如果栈为空则返回null - IUiPageBehavior Peek(); + IUiPageBehavior? Peek(); /// @@ -137,4 +137,42 @@ public interface IUiRouter : ISystem void RemoveGuard(IUiRouteGuard guard); #endregion + + #region Layer UI + + /// + /// 在指定层级显示UI(Overlay / Modal / Toast等) + /// + void Show( + string uiKey, + UiLayer layer, + IUiPageEnterParam? param = null, + UiInstancePolicy instancePolicy = UiInstancePolicy.Reuse); + + /// + /// 在指定层级显示UI(基于已存在实例) + /// + void Show(IUiPageBehavior page, UiLayer layer); + + /// + /// 隐藏指定层级的UI + /// + void Hide(string uiKey, UiLayer layer, bool destroy = false); + + /// + /// 清空指定层级的所有UI + /// + void ClearLayer(UiLayer layer, bool destroy = false); + + /// + /// 从指定层级获取UI实例 + /// + IUiPageBehavior? GetFromLayer(string uiKey, UiLayer layer); + + /// + /// 判断指定层级是否存在可见UI + /// + bool HasVisibleInLayer(UiLayer layer); + + #endregion } \ No newline at end of file diff --git a/GFramework.Game/ui/UiRouterBase.cs b/GFramework.Game/ui/UiRouterBase.cs index 5f33f2d..f480281 100644 --- a/GFramework.Game/ui/UiRouterBase.cs +++ b/GFramework.Game/ui/UiRouterBase.cs @@ -267,9 +267,9 @@ public abstract class UiRouterBase : AbstractSystem, IUiRouter /// 获取页面栈顶元素,但不移除该元素 /// /// 返回栈顶的IUiPageBehavior元素 - public IUiPageBehavior Peek() + public IUiPageBehavior? Peek() { - return _stack.Peek(); + return _stack.Count == 0 ? null : _stack.Peek(); }