private BasePanel LoadPanel(UIID panelName) { string uiPath = null; GameObject cloneUIPrefabs = null; BasePanel basePanel = null; m_DicUIPrefabPath.TryGetValue(panelName, out uiPath); if (!string.IsNullOrEmpty(uiPath)) { //Test 需要重新改成ab Log.i("加载" + panelName); cloneUIPrefabs = Instantiate(Resources.Load(uiPath)) as GameObject;//通过名称路径加载预设的克隆体 cloneUIPrefabs.name = panelName.ToString(); } if (root != null && cloneUIPrefabs != null) { basePanel = cloneUIPrefabs.GetComponent <BasePanel>(); if (basePanel == null) { Log.e("UIPrefab is null! Plz check UIPrefab!"); return(null); } switch (basePanel.formType) { case UIFormType.Normal: cloneUIPrefabs.transform.SetParent(normalRoot, false); break; case UIFormType.Fixed: cloneUIPrefabs.transform.SetParent(fixedRoot, false); break; case UIFormType.PopUp: cloneUIPrefabs.transform.SetParent(popupRoot, false); break; case UIFormType.None: break; } cloneUIPrefabs.SetActive(false); m_DicAllPanel.Add(panelName, basePanel); return(basePanel); } else { Log.e("root or cloneUIPrefab is null!Plz check panelName=" + panelName); } return(null); }
/// <summary> /// 弹窗出栈 /// </summary> private void PopUIPanel() { if (m_StaCurrentPanel.Count > 2) { //出栈 BasePanel topPanel = m_StaCurrentPanel.Pop(); topPanel.Hide(); BasePanel nextPanel = m_StaCurrentPanel.Peek(); nextPanel.ReDisplay(); } else if (m_StaCurrentPanel.Count == 1) { //出栈 BasePanel topPanel = m_StaCurrentPanel.Pop(); topPanel.Hide(); } }
/// <summary> /// 弹窗入栈 /// </summary> /// <param name="panelName"></param> private void PushPanel2Stack(UIID panelName) { BasePanel basePanel; if (m_StaCurrentPanel.Count > 0) { BasePanel topPanel = m_StaCurrentPanel.Peek(); topPanel.Freeze(); } m_DicAllPanel.TryGetValue(panelName, out basePanel); if (basePanel != null) { basePanel.Display(); m_StaCurrentPanel.Push(basePanel); } else { Log.i("basePanel is null ,plz check panelName={0}", panelName); } }