public void Refresh(UIType curType, UIType nextType) { BaseView curView = UIManager.Instance.TryGetSingleUI(curType).GetComponent <BaseView>(); BaseView nextView = null; GameObject next = UIManager.Instance.TryGetSingleUI(nextType); if (next != null) { nextView = next.GetComponent <BaseView>(); } foreach (var k in type2Context.Keys) { if (!curView.commonUI2Show.Contains(k) && (nextView == null || !nextView.commonUI2Show.Contains(k))) { GameObject go = UIManager.Instance.TryGetSingleUI(k); if (go != null) { go.GetComponent <BaseCommonView>().OnExit(type2Context[k]); go.GetComponent <BaseCommonView>().linkedView = null; } } } if (nextView != null) { for (int i = 0; i < nextView.commonUI2Show.Count; i++) { UIType commonType = nextView.commonUI2Show[i]; if (curView.commonUI2Show.Contains(commonType)) { continue; } AddCommonUI(commonType, nextView); } } for (int i = 0; i < curView.commonUI2Show.Count; i++) { AddCommonUI(curView.commonUI2Show[i], curView); } }
public void Pop() { UIType curType = UIType.None; UIType nextType = UIType.None; if (_contextStack.Count != 0) { BaseContext curContext = _contextStack.Peek(); _contextStack.Pop(); BaseView curView = UIManager.Instance.GetSingleUI(curContext.ViewType).GetComponent <BaseView>(); curView.OnExit(curContext); } if (_contextStack.Count != 0) { BaseContext lastContext = _contextStack.Peek(); curType = lastContext.ViewType; _curContext = lastContext; BaseView curView = UIManager.Instance.GetSingleUI(lastContext.ViewType).GetComponent <BaseView>(); curView.transform.SetAsLastSibling(); if (!curView.hasEnter) { curView.OnEnter(lastContext); curView.OnPause(lastContext); } curView.OnResume(lastContext); if (curView.closeOtherUI) { UIManager.Instance.CloseAllUI(); } if (!UIManager.Instance.activeView.Contains(curView)) { UIManager.Instance.activeView.Add(curView); } } DisableInstant(); UIManager.Instance.commonUIManager.Refresh(curType, nextType); }
public BaseContext(UIType viewType) { ViewType = viewType; }
/// <summary> /// 显示UI界面 /// <param name="uiType">界面类型</param> /// <param name="uiLayer">UI的属于哪个层级</param> /// <param name="isReapt">是否可以同时显示多个类型相同的界面</param> /// <returns>BaseView</returns> public T ShowView <T>(UIType uiType, bool isReapt = false) { return((T)(object)CreateView(uiType, isReapt)); }
/// <summary> /// 显示UI界面 /// <param name="uiType">界面类型</param> /// <param name="uiLayer">UI的属于哪个层级</param> /// <param name="isReapt">是否可以同时显示多个类型相同的界面</param> /// <returns></returns> public void ShowView(UIType uiType, bool isReapt = false) { CreateView(uiType, isReapt); }
protected void RegistCommonView(UIType uiType) { commonUI2Show.Add(uiType); }