public void GetUIByType(UIType type, OnGetViewBaseHandler onGetViewBaseHandler, bool syncLoad = false) { if (_activeUIDic.ContainsKey(type)) { // Current UI are active. onGetViewBaseHandler.Invoke(_activeUIDic[type], type); } else { if (_inactiveUIDic.ContainsKey(type)) { // Current UI game object can be find in uiPool. ResumeView(type, _inactiveUIDic[type], onGetViewBaseHandler); } else { // Get current UI at first time. if (_waitingUILoadedDic.ContainsKey(type)) { _waitingUILoadedDic[type] += onGetViewBaseHandler; } else { _waitingUILoadedDic.Add(type, onGetViewBaseHandler); StartLoadView(type, syncLoad); } } } }
private void ResumeView(UIType uiType, ViewBase ui, OnGetViewBaseHandler onResumUI) { if (ui != null) { ChangeUIViewDepthBySetParent(ui.transform, ui.uiMenuDepth); ui.transform.localPosition = Vector3.zero; ui.transform.localScale = Vector3.one; _inactiveUIDic.Remove(ui.uiType); _activeUIDic.Add(ui.uiType, ui); onResumUI(ui, ui.uiType); } else { DebugUtils.LogError(DebugUtils.Type.UI, string.Format(" Can't find inactive ui, uiType = {0}", uiType)); } }