Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public static void UnRegisterPanel(BasePanel type)
 {
 }
Esempio n. 6
0
        // Actions
        // =====================================================================

        public void AddPanelToOverlayList(BasePanel panel)
        {
            _panelsWithOverlay.Add(panel);
            overlayButton.gameObject.SetActive(true);
        }
Esempio n. 7
0
        public void OpenWin(UIPanelType type, bool closeOther)
        {
            BasePanel target = UIPanelRegister.GetPanel(type);

            OpenWin(target, Vector3.zero, closeOther);
        }
Esempio n. 8
0
 public void OpenWin(BasePanel panel, bool closeOther)
 {
     OpenWin(panel, closeOther);
 }