예제 #1
0
        /// <summary>
        /// 根据面板类型得到实例化面板
        /// </summary>
        private IBasePanel GetPanel(string panelName)
        {
            if (panelDict == null)
            {
                panelDict = new Dictionary <string, IBasePanel>();
            }

            IBasePanel panel = panelDict.TryGet(panelName);

            if (panel == null)
            {
                //如果找不到 就实例
                UIPanelInfo pInfo = panelInfoDict.TryGet(panelName);
                if (pInfo == null)
                {
                    Debug.LogError("没有该面板的信息" + panelName);
                    return(null);
                }

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

                switch (pInfo.layer)
                {
                case UILayer.Background:
                    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.panelName + "没有设置层级");
                    break;
                }
                instPanel.transform.ResetLocal();

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

                panelDict.Add(panelName, panel);
                panel.Init();
            }
            return(panel);
        }
예제 #2
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);
        }