Exemplo n.º 1
0
        private UIRoot LoadUIRoot()
        {
            ResLoader loader = ResLoader.Allocate("UIMgr");

            // loader.Add2Load(UIROOTPATH);
            // loader.LoadSync();

            UnityEngine.Object uiRootObj = loader.LoadSync(UIROOTPATH);
            if (uiRootObj == null)
            {
                Log.e("Failed To Load UIRoot at" + UIROOTPATH);
                return(null);
            }
            GameObject uiRootGo = GameObject.Instantiate(uiRootObj as GameObject);

            return(uiRootGo.GetComponent <UIRoot>());
        }
Exemplo n.º 2
0
        public void OpenPanel <T>(T uiID, PanelType panelType, Action <AbstractPanel> listener, params object[] args) where T : IConvertible
        {
            UIData uIData = UIDataTable.Get(uiID);

            if (uIData == null)
            {
                Log.e("#Not find UIID:" + uiID);
                return;
            }

            if (m_Loader == null)
            {
                m_Loader = ResLoader.Allocate("UIMGR");
            }


            // m_Loader.Add2Load(uIData.fullPath, (state, res) =>
            // {
            //     if (!state)
            //     {
            //         return;
            //     }
            // });
            // m_Loader.LoadSync();
            GameObject prefab = m_Loader.LoadSync(uIData.fullPath) as GameObject;
            GameObject obj    = GameObject.Instantiate(prefab);
            var        panel  = obj.GetComponent <AbstractPanel>();

            panel.UIID = uIData.UIID;
            if (panel == null)
            {
                return;
            }

            obj.transform.SetParent(uiRoot.panelRoot);
            obj.transform.Reset();

            RectTransform rect = obj.GetComponent <RectTransform>();

            rect.SetAnchor(AnchorPresets.StretchAll);
            rect.SetSize(new Vector2(uiRoot.rootCanvas.pixelRect.width, uiRoot.rootCanvas.pixelRect.height));
        }