Beispiel #1
0
        public static List <UIPanelInfo> ReadExcel(string ePath)
        {
            List <UIPanelInfo> testDict = new List <UIPanelInfo>();

            using (FileStream stream = File.Open(excelPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream))
                {
                    excelReader.Read();
                    //除了第一行的字段名 和最后一行空白
                    for (int i = 1; i < excelReader.RowCount; i++)
                    {
                        excelReader.Read();
                        UIPanelInfo pdata = new UIPanelInfo();
                        //数字类型需要转换
                        pdata.id        = int.Parse(excelReader.GetString(0));
                        pdata.panelName = excelReader.GetString(1);
                        pdata.path      = excelReader.GetString(2);
                        pdata.layer     = excelReader.GetString(3);

                        testDict.Add(pdata);
                    }
                }
            }

            return(testDict);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }