/// <summary> /// 出栈 UIPanel,隐藏当前的UIPanel,并恢复上一界面的状态 /// </summary> public void PopUIPanel() { //安全校验,如果栈为空, new 一个 if (panelStack == null) { panelStack = new Stack <BaseUIPanel>(); } // 安全校验,因为是出栈,所以先判断,栈是否为空,空则返回,不进行出栈 if (panelStack.Count <= 0) { return; } //出栈,并获得栈顶的 UIPanel //栈顶的 UIPanel,进行退出回调操作 BaseUIPanel topPanel = panelStack.Pop(); topPanel.OnExitCallBack(); // 安全校验,因为是出栈,所以先判断,栈是否为空,空则返回,不进行出栈 if (panelStack.Count <= 0) { return; } // 出栈后,获取新栈顶成员,并进行恢复操作 topPanel = panelStack.Peek(); topPanel.OnResumeCallBack(); }
/// <summary> /// 把UIPanel入栈,显示UI,如果之前有UI则暂停当前UIPanel /// </summary> /// <param name="panelType">UIPanel 的哪个UIPanel</param> public void PushUIPanel(UIPanelType panelType) { //安全校验,如果栈为空, new 一个 if (panelStack == null) { panelStack = new Stack <BaseUIPanel>(); } //判断栈内是否有成员,有则获得当前UIPanel,暂停当前 UIPanel if (panelStack.Count > 0) { BaseUIPanel topPanel = panelStack.Peek(); topPanel.OnPauseCallBack(); } //根据 UIPanelType 获得 UIPanel 实体 //引进该 UIPanel 并且显示 //把该 UIPanel 入栈 BaseUIPanel panel = GetUIPanelByPanelType(panelType); panel.OnEnterCallBack(); panelStack.Push(panel); }