public void Release() { if (_allUIView == null) { return; } for (UI_TYPE i = UI_TYPE.UI_NONE; i < UI_TYPE.UI_MAX; ++i) { BaseUIView uiView = null; if (_allUIView.TryGetValue(i, out uiView)) { if (uiView != null) { if (!uiView.IsClose()) { uiView.Hide(); } uiView.Release(); GameObject.Destroy(uiView.gameObject); } } } _UICamera = null; _allUIView.Clear(); _backUIViewQueue.Clear(); Resources.UnloadUnusedAssets(); }
public BaseUIView OpenUIView(UI_TYPE uiType, object param = null) { BaseUIView baseUIView = null; if (!_allUIView.TryGetValue(uiType, out baseUIView)) { string uiAssetPath = GetUIAssetPathByUIType(uiType); GameObject goUI = GameObject.Instantiate(Resources.Load <GameObject>(uiAssetPath)); baseUIView = goUI.GetComponent <BaseUIView>(); _allUIView.Add(uiType, baseUIView); } else { if (!baseUIView.IsClose()) { baseUIView.Hide(); } } if (baseUIView.IsNeedBack()) { for (int i = 0, len = _backUIViewQueue.Count; i < len; ++i) { BaseUIView tempUIView = _backUIViewQueue[i]; if (tempUIView.Equals(baseUIView)) { _backUIViewQueue.RemoveAt(i); break; } } _backUIViewQueue.Add(baseUIView); } if (_openUIViewQueue.Contains(baseUIView)) { _openUIViewQueue.Remove(baseUIView); } _openUIViewQueue.Add(baseUIView); ChangeUIViewParent(baseUIView); HideOldView(); baseUIView.UIType = uiType; if (baseUIView.IsShowAfterOpenEffect) { baseUIView.UIParam = param; baseUIView.ShowOpenEffect(); } else { baseUIView.Show(param); } baseUIView.ChangeCameraRenderTexture(true); baseUIView.ChangeCanvasLayer(UILayer); baseUIView.ChangeGraphicRaycasterState(true); RefreshUISortingOrder(); return(baseUIView); }
public bool IsUIOpen(UI_TYPE uiType) { BaseUIView baseUIView = null; if (_allUIView.TryGetValue(uiType, out baseUIView)) { return(!baseUIView.IsClose()); } return(false); }