private BasePanel GetPanel(UIPanelType panelType) { if (panelDict == null) { panelDict = new Dictionary <UIPanelType, BasePanel>(); } BasePanel panel = panelDict.GetValue(panelType); //如果没有实例化面板,寻找路径进行实例化,并且存储到已经实例化好的字典面板中 if (panel == null) { string path = panelPathDict.GetValue(panelType.ToString()); GameObject panelGo = GameObject.Instantiate(Resources.Load <GameObject>(path), CanvasTransform, false); panel = panelGo.GetComponent <BasePanel>(); panelDict.Add(panelType, panel); } return(panel); }
public void PushPanel(UIPanelType panelType) { if (panelStack == null) { panelStack = new Stack <BasePanel>(); } //停止上一个界面 if (panelStack.Count > 0) { BasePanel topPanel = panelStack.Peek(); topPanel.OnPause(); } BasePanel panel = GetPanel(panelType); panelStack.Push(panel); panel.OnEnter(); }
public void PopPanel() { if (panelStack == null) { panelStack = new Stack <BasePanel>(); } if (panelStack.Count <= 0) { return; } //退出栈顶面板 BasePanel topPanel = panelStack.Pop(); topPanel.OnExit(); //恢复上一个面板 if (panelStack.Count > 0) { BasePanel panel = panelStack.Peek(); panel.OnResume(); } }
public void OpenWin(BasePanel panel, Vector3 pos, bool closeOther = false) { if (panelStack.Count != 0) { BasePanel top = null; if (closeOther) { top = panelStack.Pop(); } else { top = panelStack.Peek(); } if (null != top) { top.OnExit(); } } panel.transform.localPosition = pos; panel.OnEnter(); panelStack.Push(panel); }
public static void UnRegisterPanel(BasePanel type) { }
// Actions // ===================================================================== public void AddPanelToOverlayList(BasePanel panel) { _panelsWithOverlay.Add(panel); overlayButton.gameObject.SetActive(true); }
public void OpenWin(UIPanelType type, bool closeOther) { BasePanel target = UIPanelRegister.GetPanel(type); OpenWin(target, Vector3.zero, closeOther); }
public void OpenWin(BasePanel panel, bool closeOther) { OpenWin(panel, closeOther); }