Пример #1
0
        /// <summary>
        /// 加载面板
        /// </summary>
        /// <param name="panel"></param>
        public void Open(UIPanelBase panel)
        {
            UIPanels.SetActive(true);
            //如果已经打开,就跳回此面板
            if (uiStack.Contains(panel))
            {
                GoPanel(panel);
                return;
            }
            //暂停上一层面板,停止其交互
            if (uiStack.Count > 0)
            {
                UIPanelBase uIPanelBase1 = uiStack.Peek();
                uIPanelBase1.OnPause();
                //var cg1 = GetCanvasGroup(uIPanelBase1);
                //cg1.interactable = false;
            }
            //如果隐藏就激活
            if (!panel.gameObject.activeSelf)
            {
                panel.gameObject.SetActive(true);
            }
            //进入目标面板
            panel.OnEnter();
            //CanvasGroup cg = GetCanvasGroup(panel);

            switch (panel.showType)
            {
            case UIPanelBase.ShowType.normal:
                break;

            case UIPanelBase.ShowType.hideOtherPanels:

                HideOtherPanels();
                break;

            default:
                break;
            }
            //入栈
            if (uiStack.Count == 0 || !uiStack.Peek().Equals(panel))
            {
                print("入栈" + panel.name);
                uiStack.Push(panel);
            }
            //显示并启用当前面板的交互
            //cg.blocksRaycasts = true;
            OpenByEffect(panel);
            //放在屏幕最前端
            panel.gameObject.transform.SetAsLastSibling();
        }