Пример #1
0
    public void OpenPanel(UIPanelTypes panelType)
    {
        BasePanel bp = null;
        PanelInfo pi = null;

        if (panelStack.Count > 0)
        {
            bp = panelStack.Peek();
            bp.OnPause();
        }
        if (panelDict.Contains(GetBasePanel(panelType)))
        {
            bp = GetBasePanel(panelType);
            panelStack.Push(bp);
            bp.OnShow();
        }
        else
        {
            pi = GetPanelInfo(panelType);
            if (pi == null)
            {
                Debug.LogError(panelType + ":无法打开此前页面");
                return;
            }
            GameObject instPanel = GameObject.Instantiate(Resources.Load(pi.PanelPath)) as GameObject;
            instPanel.transform.SetParent(CanvasTransform, false);
            BasePanel bw = instPanel.GetComponent <BasePanel>();
            bw.Copy(pi);
            panelDict.Add(bw);
            panelStack.Push(bw);
            bw.OnBeforeEnter();
            bw.OnEnter();
        }
    }