public void HideUI(string uiName) { if (!m_uiDic.ContainsKey(uiName)) { return; } Jyx2_UIBase uibase = m_uiDic[uiName]; if (m_normalUIStack.Contains(uibase)) { PopUI(uibase, m_normalUIStack); } else if (m_PopUIStack.Contains(uibase)) { PopUI(uibase, m_PopUIStack); } else if (uibase.Layer == UILayer.MainUI) { uibase.Hide(); } else { uibase.Hide(); } }
void PushUI(Jyx2_UIBase uibase) { switch (uibase.Layer) { case UILayer.MainUI: if (m_currentMainUI && m_currentMainUI != uibase) { m_currentMainUI.Hide(); } m_currentMainUI = uibase; break; case UILayer.NormalUI: m_normalUIStack.Push(uibase); break; case UILayer.PopupUI: m_PopUIStack.Push(uibase); break; } }
void PopUI(Jyx2_UIBase ui, Stack <Jyx2_UIBase> uiStack) { if (!uiStack.Contains(ui)) { return; } Jyx2_UIBase node = uiStack.Pop(); while (node) { if (node == ui) { node.Hide(); return; } if (uiStack.Count <= 0) { return; } node.Hide(); node = uiStack.Pop(); } }
//UI加载完后的回调 void OnUILoaded(GameObject go) { string uiName = go.name.Replace("(Clone)", ""); object[] allParams = _loadingUIParams[uiName]; Component com = GameUtil.GetOrAddComponent(go.transform, uiName); Jyx2_UIBase uibase = com as Jyx2_UIBase; Transform parent = GetUIParent(uibase.Layer); go.transform.SetParent(parent); uibase.Init(); m_uiDic[uiName] = uibase; if (uibase.IsOnly)//如果这个层唯一存在 那么先关闭其他 { PopAllUI(uibase.Layer); } PushUI(uibase); uibase.Show(allParams); _loadingUIParams.Remove(uiName); }