public void LoadPanelRes() { if (m_PanelState != ePanelState.UnInit) { return; } m_PanelState = ePanelState.Loading; UIData data = UIDataTable.Get(m_UIID); if (data == null) { return; } GameObject prefab = ResMgr.S.GetRes(data.fullPath).asset as GameObject; LoadResSuccess(prefab); }
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)); }
private PanelInfo LoadPanelInfo(int uiID) { UIData data = UIDataTable.Get(uiID); if (data == null) { Log.e("#Not Find UIData for UIID:" + uiID); return(null); } bool needAdd = true; PanelInfo panelInfo = GetPanelFromCache(uiID, true); if (panelInfo == null)//没有缓存 { if (data.isSingleton) { panelInfo = GetPanelFromActive(uiID); } if (panelInfo == null) { panelInfo = ObjectPool <PanelInfo> .S.Allocate(); panelInfo.Init(uiID, nextPanelID); } else { needAdd = false; } } if (needAdd) { AddPanelInfo(panelInfo); } return(panelInfo); }
private void ClosePanelInfo(PanelInfo panelInfo) { if (panelInfo == null) { return; } UIData data = UIDataTable.Get(panelInfo.uiID); bool destory = true; if (data != null && data.cacheCount > 0) { if (GetActiveAndCachedUICount(panelInfo.uiID) <= data.cacheCount) { destory = false; } } RemovePanelInfo(panelInfo); //恢复层级记录 m_UIRoot.ReleasePanelSortingOrder(panelInfo.sortingOrder); if (destory) { panelInfo.ClosePanel(true); } else { m_CachedPanelList.Add(panelInfo); panelInfo.ClosePanel(false); } if (destory) { ObjectPool <PanelInfo> .S.Recycle(panelInfo); } }