BaseUI FindLastIdenticalLayerUI(EUIType type, EUILayer layer) { BaseUI ui = null; if (type == EUIType.FullScreen) { ui = _OpenedFullScreenUI.FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer); } else if (type == EUIType.Coexisting) { if (CurFullScreenUI != null && _CoexistingUI.ContainsKey(CurFullScreenUI)) { ui = _CoexistingUI[CurFullScreenUI].FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer); } } else if (type == EUIType.Independent) { ui = _IndependentUI.FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer); } else if (type == EUIType.Resident) { ui = _ResidentUI.FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer); } return(ui); }
void InitUIParent() { _UIParent = new GameObject("UIParent").transform; UnityEngine.Object.DontDestroyOnLoad(_UIParent); var eventSystem = new GameObject("EventSystem"); var eventSys = eventSystem.AddComponent <EventSystem>(); eventSystem.AddComponent <StandaloneInputModule>(); eventSys.sendNavigationEvents = false; eventSystem.transform.SetParent(_UIParent); var ns = Enum.GetNames(typeof(EUILayer)); for (int i = 0, length = ns.Length; i < length; i++) { var n = ns[i]; EUILayer l = (EUILayer)Enum.Parse(typeof(EUILayer), n); if (!_UILayers.ContainsKey(l)) { var tf = new GameObject(n).transform; tf.SetParent(_UIParent); _UILayers.Add(l, tf); } } }
public void OpenUI(string aUIName, params object[] parms) { if (this.mUIDic.ContainsKey(aUIName) == false) { Debug.LogError("UI is not existed!"); return; } GameObject prefab = this.mUIDic[aUIName]; GameObject UIObj = GameObject.Instantiate(prefab); TUIBasePage uiPage = UIObj.GetComponent <TUIBasePage>(); EUILayer layerType = uiPage.UILayer; switch (layerType) { case EUILayer.GLOBLE: UIObj.transform.SetParent(TUIRoot.GetSingleton().GlobalUIRoot.transform, false); this.SortUILayer(TUIRoot.GetSingleton().GlobalUIRoot); break; case EUILayer.NORMAL: UIObj.transform.SetParent(TUIRoot.GetSingleton().NormalUIRoot.transform, false); this.SortUILayer(TUIRoot.GetSingleton().NormalUIRoot); break; case EUILayer.POPUP: UIObj.transform.SetParent(TUIRoot.GetSingleton().PopUIRoot.transform, false); this.SortUILayer(TUIRoot.GetSingleton().PopUIRoot); break; default: return; } uiPage.UIName = aUIName; uiPage.OnInitialize(parms); uiPage.OnShow(); this.mReadyToAddList.Add(uiPage); }