public void LoadResSuccess(GameObject prefab) { if (prefab == null) { Log.e("#Failed To Load PanelRes:" + m_PanelID); return; } //默认先挂到hide下面 不触发awake GameObject panelGo = GameObject.Instantiate(prefab, UIMgr.S.uiRoot.hideRoot, false); panelGo.SetActive(false); AbstractPanel panel = panelGo.GetComponent <AbstractPanel>(); UIMgr.S.InitPanel(panelGo); abstractPanel = panel; if (panel == null) { panelGo.SetActive(true); Log.e("Not Find Panel Class In Prefab For Panel:" + m_UIID); return; } m_PanelState = ePanelState.Ready; }
public void LoadPanelResAsync() { if (m_PanelState != ePanelState.UnInit) { return; } m_PanelState = ePanelState.Loading; UIData data = UIDataTable.Get(m_UIID); if (data == null) { return; } PrepareDynamicResource(data); m_ResLoader.Add2Load(data.fullPath, (state, res) => { if (!state) { return; } OnPanelResLoadSuccess((GameObject)res.asset); }); m_ResLoader.LoadSync(); }
public void OnCacheReset() { m_Panel = null; m_PanelState = ePanelState.UnInit; m_PanelID = -1; m_UIID = -1; m_SortingOrder = -1; m_OpenCallback = null; }
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.Instance.InstantiateUIPrefab(prefab); go.SetActive(false); UIMgr.Instance.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.Instance.SetPanelSortingOrderDirty(); }
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_CurrentMaster); 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(); }
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 OnCacheReset() { m_Panel = null; m_NextMaster = -1; m_PanelID = -1; m_UIID = -1; m_SortIndex = -1; m_PanelState = ePanelState.UnInit; m_OpenListeners = null; m_CustomVisibleFlag = true; m_ResLoader.ReleaseAllRes(); if (m_PageWrapList != null) { m_PageWrapList.Clear(); } if (m_OpenInfoList != null) { m_OpenInfoList.Clear(); } }
public void SetActive(bool visible, bool interactive) { if (m_Panel == null) { return; } visible = (visible && m_Panel.customVisibleFlag); ePanelState nextState = ePanelState.UnInit; if (visible) { if (interactive) { nextState = ePanelState.Interactive; } else { nextState = ePanelState.OnlyVisible; } } else { nextState = ePanelState.UnVisible; } if (nextState == m_PanelState) { return; } m_PanelState = nextState; //1.使用LayerMask 模式设置 if (visible) { if (!m_Panel.gameObject.activeSelf) { m_Panel.gameObject.SetActive(true); } UITools.SetGameObjectLayer(m_Panel.gameObject, LayerDefine.LAYER_UI); if (interactive) { UITools.SetGraphicRaycasterState(m_Panel.gameObject, true); } else { UITools.SetGraphicRaycasterState(m_Panel.gameObject, false); } Transform tr = m_Panel.transform; UIMgr.Instance.uiRoot.ReleaseFreePos(tr.localPosition); tr.localPosition = m_DefaultPos; m_Panel.OnBecomeVisible(); } else { UITools.SetGameObjectLayer(m_Panel.gameObject, LayerDefine.LAYER_HIDE_UI); m_Panel.gameObject.transform.localPosition = UIMgr.Instance.uiRoot.RequireNextFreePos(); m_Panel.OnBecomeHide(); } //2. 使用GameObject开关模式,经过测试每次切换的开销比较大,但是在编辑器模式下方便编辑调试 /* * if (m_Panel.gameObject.activeSelf != state) * { * m_Panel.gameObject.SetActive(state); * } */ //3.使用Canvas 组件的开关模式,该模式和1类似,时间上和1类似 /* * if (state) * { * if (!m_Panel.gameObject.activeSelf) * { * m_Panel.gameObject.SetActive(true); * } * * UITools.SetCanvasState(m_Panel.gameObject, true); * Transform tr = m_Panel.transform; * UIMgr.S.uiRoot.ReleaseFreePos(tr.localPosition); * tr.localPosition = m_DefaultPos; * } * else * { * UITools.SetCanvasState(m_Panel.gameObject, false); * m_Panel.gameObject.transform.localPosition = UIMgr.S.uiRoot.RequireNextFreePos(); * } */ }