Beispiel #1
0
        public static UIPanelInfo GetPanelInfo(UIPanelName name)
        {
            var index = (int)name;

            if (index < panelInfoArr.Length)
            {
                return(panelInfoArr[(int)name]);
            }
            Debug.LogError("没有该面板的PanelInfo:" + name.ToString());
            throw new System.Exception();
        }
Beispiel #2
0
        public void Show(UIPanelName panelName)
        {
            IBasePanel panel = GetPanel(panelName);

            panel.rootUI.transform.SetAsLastSibling();
            panel.OnShow();

            if (!panelShowDict.ContainsKey(panelName))
            {
                panelShowDict.Add(panelName, panel);
            }
        }
Beispiel #3
0
        public static BasePanel GetPanelBusiness(UIPanelName name)
        {
            switch (name)
            {
            case UIPanelName.GameStartPanel: return(new GameStartPanel());


            default:
                Debug.LogError("不存在此面板" + name.ToString());
                return(null);
            }
        }
Beispiel #4
0
        public void Hide(UIPanelName panelName)
        {
            if (panelShowDict.Count <= 0)
            {
                return;
            }

            IBasePanel panel = panelShowDict.TryGet(panelName);

            if (panel == null)
            {
                return;
            }

            panel.OnHide();
            panelShowDict.Remove(panelName);
        }
Beispiel #5
0
        /// <summary>
        /// 获取面板的游戏物体
        /// </summary>
        private GameObject GetPanelGO(UIPanelName panelName, string path)
        {
            GameObject instPanel = panelGODict.TryGet(panelName);


            if (instPanel == null)
            {
                GameObject res = ResMgr.Instance.GetRes <GameObject>(uiPrefabPath + panelName.ToString());
                instPanel      = GameObject.Instantiate(res) as GameObject;
                instPanel.name = panelName.ToString();
                panelGODict.Add(panelName, instPanel);
            }

            if (!currentScenePanelDict.ContainsKey(panelName))
            {
                currentScenePanelDict.Add(panelName, instPanel);
            }
            return(instPanel);
        }
Beispiel #6
0
        /// <summary>
        /// 根据面板类型得到实例化面板
        /// </summary>
        private IBasePanel GetPanel(UIPanelName panelName)
        {
            IBasePanel panel = panelDict.TryGet(panelName);

            if (panel == null)
            {
                //如果找不到 就实例
                UIPanelInfo pInfo = UIPanelHelper.GetPanelInfo(panelName);

                GameObject instPanel = GetPanelGO(panelName, pInfo.path);

                switch (pInfo.Layer)
                {
                case UILayer.Bottom:
                    instPanel.transform.SetParent(BGTransform, false);
                    break;

                case UILayer.Common:
                    instPanel.transform.SetParent(CommonTransform, false);
                    break;

                case UILayer.Top:
                    instPanel.transform.SetParent(TopTransform, false);
                    break;

                default:
                    Debug.LogError(pInfo.Name + "没有设置层级");
                    break;
                }
                instPanel.transform.SetParent(CommonTransform, false);
                instPanel.transform.ResetLocal();

                panel        = UIPanelHelper.GetPanelBusiness(panelName);
                panel.rootUI = instPanel;

                panelDict.Add(panelName, panel);
                panel.Init();
            }
            return(panel);
        }
Beispiel #7
0
 public void Hide(UIPanelName panelName)
 {
     uiFacade.Hide(panelName);
 }
Beispiel #8
0
 public void Show(UIPanelName panelName)
 {
     uiFacade.Show(panelName);
 }