private void AfterPush(EViewType e) { if (e == EViewType.Normal) { foreach (ViewBase view in viewStack) { if (view.gameObject.activeInHierarchy) { view.gameObject.SetActive(false); } } } else if (e == EViewType.Popup) { bool meetNormal = false; foreach (ViewBase view in viewStack) { if (meetNormal && view.gameObject.activeInHierarchy) { view.gameObject.SetActive(false); } else if (!view.gameObject.activeInHierarchy) { view.gameObject.SetActive(true); } ViewPropertySt st = ViewPropertyDefinition.GetSt(view.GetType()); if (st.eViewType == EViewType.Normal) { meetNormal = true; } } } }
public void Open <T>() where T : ViewBase { System.Type t = typeof(T); ViewBase view = Contains(t); ViewPropertySt str = ViewPropertyDefinition.GetSt(t); AfterPush(str.eViewType); if (view != null) { view.gameObject.SetActive(true); viewStack.Push(view); } else { if (str.IsNull()) { throw new MissingReferenceException("view path is null"); } AssetBundleManager.Instance.Load(str.path, (abi) => { GameObject gameObj = GameObject.Instantiate(abi.mainObject) as GameObject; Mount2UILayer(str.eViewType, gameObj); view = gameObj.AddComponent <T>(); viewStack.Push(view); IfUseMask(); }); } }
private void IfUseMask() { if (viewStack.Count <= 0) { return; } ViewBase v = viewStack.Peek(); ViewPropertySt str = ViewPropertyDefinition.GetSt(v.GetType()); EViewType e = str.eViewType; if (e == EViewType.Popup && !alphaMask.activeInHierarchy) { alphaMask.SetActive(true); } else if (e == EViewType.Normal && alphaMask.activeInHierarchy) { alphaMask.SetActive(false); } }
public void Close <T>() where T : ViewBase { System.Type t = typeof(T); ViewBase view = viewStack.Peek(); if (view == null) { throw new System.ArgumentException("not a view exit"); } else if (view.GetType() != t) { throw new System.ArgumentException("close a view not at top"); } else { viewStack.Pop(); GameObject.Destroy(view.gameObject); ViewPropertySt str = ViewPropertyDefinition.GetSt(t); AfterPop(str.eViewType); IfUseMask(); } }