public void Uninstall() { while (_stackCurrentUI.Count > 0) { BaseUI ui = _stackCurrentUI.Pop(); ui.Close(true); } if (_dictLoadedAllUIs != null) { var list = _dictLoadedAllUIs.ToList(); for (int i = list.Count - 1; i >= 0; i--) { Close(list[i].Key, true); } list = null; } _allRegisterUIList.Clear(); _stackCurrentUI.Clear(); _dictCurrentShowUIs.Clear(); TransFixed = null; TransPopUp = null; TransRoot = null; TransNormal = null; TransGlobal = null; RectransGlobal = null; RectransFixed = null; RectransNormal = null; RectransPopUp = null; RectransRoot = null; _stackCurrentUI = null; _allRegisterUIList = null; _dictLoadedAllUIs = null; _dictCurrentShowUIs = null; DelHideCallBack = null; LoadResourceFunc = null; Resources.UnloadUnusedAssets(); }
/// <summary> /// 弹出窗口,出栈 /// </summary> /// <param name="uiName"></param> private void UnLoadStackUI(string uiName, bool isDestroy = false) { //有两个以上弹窗出现时 if (_stackCurrentUI.Count >= 2) { //第一个出栈 BaseUI topUI = _stackCurrentUI.Pop(); topUI.Close(isDestroy: isDestroy); //第二个重新显示 BaseUI nextUI = _stackCurrentUI.Peek(); nextUI.Show(true); } //当前只有一个弹窗 else if (_stackCurrentUI.Count == 1) { //出栈的窗体进行隐藏 BaseUI topUI = _stackCurrentUI.Pop(); topUI.Close(isDestroy: isDestroy); } }
/// <summary> /// 弹出窗口,入栈 /// 先冻结栈中窗口,再将此窗口入栈 /// </summary> /// <param name="uiName"></param> private void LoadStackUI(string uiName) { BaseUI baseUI; //判断栈里是否有窗口,有则冻结响应 if (_stackCurrentUI.Count > 0) { BaseUI topUI = _stackCurrentUI.Peek(); if (!topUI.AssetsName.Equals(uiName)) { topUI.Close(freeze: true); } } //获取当前UI,进行展示处理 _dictLoadedAllUIs.TryGetValue(uiName, out baseUI); if (baseUI != null) { if (baseUI.IsShowing) { baseUI.OnShow(); } else { if (baseUI.IsInitOver) { baseUI.OnEnabled(false); } baseUI.Show(); } if (!_stackCurrentUI.Contains(baseUI)) { //该弹出UI入栈 _stackCurrentUI.Push(baseUI); } else //对于栈内存在,则将其提升至栈顶 { while (_stackCurrentUI.Count > 0) { var ui = _stackCurrentUI.Pop(); if (ui != baseUI) { _backStack.Push(ui); } } while (_backStack.Count > 0) { _stackCurrentUI.Push(_backStack.Pop()); } _stackCurrentUI.Push(baseUI); } } else { throw new Exception("UIManager catch an error"); } }