private void LoadNextPanelRes() { if (m_NextPanelResLoader != null) { m_NextPanelResLoader.ReleaseAllRes(); } else { m_NextPanelResLoader = ResLoader.Allocate("SwitchAnimPanel"); } if (m_OpenParam.nextPanelUIID < 0) { OnNextPanelResLoadFinish(); } UIData data = UIDataTable.Get(m_OpenParam.nextPanelUIID); if (data == null) { return; } UIMgr.CollectDynamicResource(data, m_NextPanelResLoader, m_OpenParam.args); m_NextPanelResLoader.Add2Load(data.fullPath); m_NextPanelResLoader.LoadAsync(OnNextPanelResLoadFinish); }
public void ShortCachePanel <T>(T uiID) where T : IConvertible { UIData data = UIDataTable.Get(uiID.ToInt32(null)); if (data == null) { return; } ++data.shortCacheCount; }
public void Start(Action <bool, ITrigger> l) { if (m_BlackList == null) { m_BlackList = new int[2]; m_BlackList[0] = UIDataTable.PanelName2UIID("GuideHandPanel"); m_BlackList[1] = UIDataTable.PanelName2UIID("HighlightMaskPanel"); } m_Listener = l; EventSystem.S.Register(EngineEventID.OnPanelUpdate, OnPanelUpdte); }
private void ClosePanelInfo(PanelInfo panelInfo) { if (panelInfo == null) { return; } //删除对自己的引用 panelInfo.RemoveMaster(panelInfo.panelID); if (panelInfo.nextMaster > 0) { //重新调整层级就行 } else //该面板已经没有任何依赖 { UIData data = UIDataTable.Get(panelInfo.uiID); bool destroy = true; if (data != null && data.cacheCount > 0) { if (GetActiveAndCachedUICount(panelInfo.uiID) <= data.cacheCount) { destroy = false; } } RemovePanelInfo(panelInfo); //恢复层级记录 m_UIRoot.ReleasePanelSortingOrder(panelInfo.sortIndex); //处理是否真正销毁面板逻辑 if (destroy) { panelInfo.ClosePanel(destroy); } else { m_CachedPanelList.Add(panelInfo); panelInfo.ClosePanel(destroy); } //该面板的删除将影响它的依赖面板 CheckNeedClosePanel(panelInfo.panelID); if (destroy) { ObjectPool <PanelInfo> .S.Recycle(panelInfo); } } }
public void LoadPageResAsync(int uiID, Transform parent, bool singleton, Action <AbstractPage> listener) { UIData data = UIDataTable.Get(uiID); if (data == null) { Log.e("Failed to load UI, Not Find UIData For:" + uiID); return; } if (singleton) { if (m_PageWrapList == null) { m_PageWrapList = new List <PageWrap>(); } PageWrap wrap = FindPageWrap(uiID); if (wrap != null) { wrap.AddListener(listener); return; } else { wrap = new PageWrap(uiID); wrap.AddListener(listener); m_PageWrapList.Add(wrap); } } if (m_ResLoader == null) { m_ResLoader = ResLoader.Allocate("PanelInfo"); } CollectDynamicResource(data, m_ResLoader); m_ResLoader.Add2Load(data.fullPath, (state, res) => { if (!state) { return; } OnPageResLoadSuccess(uiID, parent, (GameObject)res.asset, singleton, listener); }); m_ResLoader.LoadSync(); }
private void OnPanelResLoadSuccess(GameObject prefab) { if (m_NextMaster < 0) { Log.i("PanelInfo Already Close,But Still Call OnPanelResLoadSuccess"); m_PanelState = ePanelState.UnInit; return; } if (prefab == null) { UIData data = UIDataTable.Get(m_UIID); Log.e(string.Format("Failed to Load UI Prefab:{0} Path:{1}", m_UIID, data.fullPath)); return; } m_PanelState = ePanelState.Ready; GameObject go = UIMgr.S.InstantiateUIPrefab(prefab); go.SetActive(false); UIMgr.S.InitPanelParem(go); AbstractPanel panel = go.GetComponent <AbstractPanel>(); if (panel == null) { //该类型面板不纳入管理 go.gameObject.SetActive(true); Log.e("Not Find Panel Class In Prefab For Panel:" + m_UIID); //需要删除PanelInfo From Activity. return; } panel.customVisibleFlag = m_CustomVisibleFlag; UIData panelData = UIDataTable.Get(m_UIID); if (panelData.panelClassType != null) { if (panel.GetType() != panelData.panelClassType) { Log.e("ERROR: Prefab Bind C# Class Is Not Same With Define:" + panelData.name); } } abstractPanel = panel; UIMgr.S.SetPanelSortingOrderDirty(); }
private AbstractPage ProcessAttachPage(int panelID, int uiID, GameObject go) { if (go == null) { return(null); } PanelInfo panelInfo = FindPanelInfoByPanelID(panelID); if (panelInfo == null || panelInfo.abstractPanel == null) { Log.e("AttachPage Failed To Find Panel:" + panelID); return(null); } panelInfo.SetSortingOrderDirty(); AbstractPage page = go.GetComponent <AbstractPage>(); if (page == null) { Log.e("Failed To Find Page In UI:" + uiID); go.SetActive(true); SetPanelSortingOrderDirty(); return(null); } UIData panelData = UIDataTable.Get(uiID); if (panelData.panelClassType != null) { if (page.GetType() != panelData.panelClassType) { Log.e("ERROR: Prefab Bind C# Class Is Not Same With Define:" + panelData.name); } } page.parentPage = panelInfo.abstractPanel; page.uiID = uiID; go.SetActive(true); page.OpenPage(); SetPanelSortingOrderDirty(); return(page); }
public void LoadPanelResAsync() { if (m_PanelState != ePanelState.UnInit) { return; } m_PanelState = ePanelState.Loading; UIData data = UIDataTable.Get(m_UIID); if (data == null) { return; } OpenParam info = GetOpenInfo(m_NextMaster); object[] args = null; if (info != null) { args = info.Args; } if (m_ResLoader == null) { m_ResLoader = ResLoader.Allocate("PanelInfo"); } CollectDynamicResource(data, m_ResLoader, args); m_ResLoader.Add2Load(data.fullPath, (state, res) => { if (!state) { return; } OnPanelResLoadSuccess((GameObject)res.asset); }); m_ResLoader.LoadSync(); }
private PanelInfo LoadPanelInfo(int uiID) { UIData data = UIDataTable.Get(uiID); if (data == null) { Log.e("Failed to OpenPanel, Not Find UIData for UIID:" + uiID); return(null); } bool needAdd = true; PanelInfo panelInfo = GetPanelFromCache(uiID, true); if (panelInfo == null) { //缓存中没有,判断当前Panel 是否只支持单例 if (data.isSingleton) { //去当前所有已经开启的面板中寻找 panelInfo = GetPanelFromActive(uiID); } if (panelInfo == null) { panelInfo = ObjectPool <PanelInfo> .S.Allocate(); panelInfo.Set(uiID, nextPanelID); } else { needAdd = false; } } if (needAdd) { AddPanelInfo(panelInfo); } return(panelInfo); }
public void UnShortCachePanel <T>(T uiID, bool clean = true) where T : IConvertible { UIData data = UIDataTable.Get(uiID.ToInt32(null)); if (data == null) { return; } --data.shortCacheCount; if (data.cacheCount > 0) { return; } if (!clean) { return; } for (int i = m_CachedPanelList.Count - 1; i >= 0; --i) { if (i >= m_CachedPanelList.Count) { continue; } PanelInfo panelInfo = m_CachedPanelList[i]; UIData data2 = UIDataTable.Get(panelInfo.uiID); if (data2.cacheCount < 1) { m_CachedPanelList.RemoveAt(i); GameObject.Destroy(panelInfo.abstractPanel.gameObject); ObjectPool <PanelInfo> .S.Recycle(panelInfo); } } }
public static RectTransform FindTransformInPanel(string targetPanelName, string targetUINodePath) { UIData data = UIDataTable.Get(targetPanelName); if (data == null) { return(null); } //string panelName = string.Format("{0}(Clone)", targetPanelName); AbstractPanel panel = UIMgr.S.FindPanel(data.uiID); //UIMgr.S.uiRoot.panelRoot.Find(targetPanelName); if (panel == null) { return(null); } Transform targetPanel = panel.transform; if (targetPanel == null) { //Log.w("# FindTransformInPanel Not Find Panel:" + panelName); return(null); } if (string.IsNullOrEmpty(targetUINodePath)) { return(targetPanel as RectTransform); } RectTransform result = targetPanel.Find(targetUINodePath) as RectTransform; if (result == null || !result.gameObject.activeSelf) { //Log.w(string.Format("# FindTransformInPanel Not Find Node:{0}/{1}", panelName, targetUINodePath)); return(null); } return(result); }
public void SetParam(object[] param) { string name = param[0] as string; m_UIID = UIDataTable.PanelName2UIID(name); }