public Coroutine OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null) { // 企图关闭当前的View Debug.Log("Open " + rViewName); MaybeCloseTopView(rViewState); return(this.StartCoroutine(Open_Async(rViewName, rViewState, rOpenCompleted))); }
/// <summary> /// 企图关闭一个当前的View,当存在当前View时候,并且传入的View是需要Dispatch的。 /// </summary> private void MaybeCloseTopView(View.State rViewState) { // 得到顶层结点 CKeyValuePair <string, View> rTopNode = null; if (this.mCurPageViews.Count > 0) { rTopNode = this.mCurPageViews.Last(); } if (rTopNode == null) { return; } string rViewGUID = rTopNode.Key; View rView = rTopNode.Value; if (rView == null) { return; } if (rViewState == View.State.PageSwitch) { // 移除顶层结点 this.mCurPageViews.Remove(rViewGUID); rView.Close(); DestroyView(rView); } }
/// <summary> /// 打开一个View /// </summary> public async Task <View> OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null) { // 企图关闭当前的View Debug.Log("-- Open UI View: " + rViewName); MaybeCloseTopView(rViewState); return(await OpenViewAsync(rViewName, rViewState, rOpenCompleted)); }
/// <summary> /// 打开一个View /// </summary> public async Task OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null) { // 企图关闭当前的View Debug.Log("Open " + rViewName); MaybeCloseTopView(rViewState); await Open_Async(rViewName, rViewState, rOpenCompleted); }
/// <summary> /// 企图关闭一个当前的View,当存在当前View时候,并且传入的View是需要Dispatch的。 /// </summary> private void MaybeCloseTopView(View.State rViewState) { // 得到顶层结点 CKeyValuePair <string, View> rTopNode = null; if (this.mCurFixedViews.Count > 0) { rTopNode = this.mCurViews.Last(); } if (rTopNode == null) { return; } string rViewGUID = rTopNode.Key; View rView = rTopNode.Value; if (rView == null) { return; } if (rViewState == View.State.dispatch) { // 移除顶层结点 this.mCurViews.Remove(rViewGUID); rView.Close(); CoroutineManager.Instance.Start(DestroyView_Async(rView)); } }
/// <summary> /// 打开一个View /// </summary> public async Task <View> OpenAsync(string rViewName, View.State rViewState, ViewModel rViewModel = null, Action <View> rOpenCompleted = null) { // 企图关闭当前的View Debug.Log("Open " + rViewName); this.MaybeCloseTopView(rViewState); return(await OpenViewAsync(rViewName, rViewState, rViewModel, rOpenCompleted)); }
/// <summary> /// 打开一个View /// </summary> public void Open(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null) { // 企图关闭当前的View MaybeCloseTopView(rViewState); this.StartCoroutine(Open_Async(rViewName, rViewState, rOpenCompleted)); }
/// <summary> /// 打开一个View /// </summary> public void Open(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null) { // 企图关闭当前的View Debug.Log("Open " + rViewName); MaybeCloseTopView(rViewState); CoroutineManager.Instance.Start(Open_Async(rViewName, rViewState, rOpenCompleted)); }
private IEnumerator Open_Async(string rViewName, View.State rViewState, Action <View> rOpenCompleted) { var rLoaderRequest = UIAssetLoader.Instance.LoadUI(rViewName); yield return(rLoaderRequest); OpenView(rViewName, rLoaderRequest.ViewPrefabGo, rViewState, rOpenCompleted); }
/// <summary> /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换 /// </summary> public void OpenView(string rViewName, GameObject rViewPrefab, View.State rViewState, Action <View> rOpenCompleted) { if (rViewPrefab == null) { return; } //把View的GameObject结点加到rootCanvas下 GameObject rViewGo = this.RootCanvas.transform.AddChild(rViewPrefab, "UI"); View rView = View.CreateView(rViewGo); if (rView == null) { Debug.LogErrorFormat("GameObject {0} has not View script.", rViewGo.name); UtilTool.SafeExecute(rOpenCompleted, null); return; } //生成GUID string rViewGUID = Guid.NewGuid().ToString(); //为View的初始化设置 rView.Initialize(rViewName, rViewGUID, rViewState); //新的View的存储逻辑 switch (rView.CurState) { case View.State.fixing: mCurFixedViews.Add(rViewGUID, rView); break; case View.State.overlap: mCurViews.Add(rViewGUID, rView); break; case View.State.dispatch: if (mCurViews.Count == 0) { mCurViews.Add(rViewGUID, rView); } else { mCurViews[mCurViews.Last().Key] = rView; } break; default: break; } rView.Open((rNewView) => { UnloadUnusedViewAssets(); UtilTool.SafeExecute(rOpenCompleted, rNewView); }); }
/// <summary> /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换 /// </summary> private void OpenView(GameObject rViewPrefab, View.State rViewState, Action <View> rOpenCompleted) { if (rViewPrefab == null) { return; } //把View的GameObject结点加到rootCanvas下 GameObject rViewGo = this.rootCanvas.transform.AddChild(rViewPrefab, "UI"); View rView = rViewGo.SafeGetComponent <View>(); if (rView == null) { Debug.LogErrorFormat("GameObject {0} has not View script.", rViewGo.name); UtilTool.SafeExecute(rOpenCompleted, null); return; } //生成GUID string rViewGUID = Guid.NewGuid().ToString(); //为View的初始化设置 rView.Initialize(rViewGUID, rViewState); //新的View的存储逻辑 switch (rView.curState) { case View.State.fixing: curFixedViews.Add(rViewGUID, rView); break; case View.State.overlap: curViews.Add(rViewGUID, rView); break; case View.State.dispatch: if (curViews.Count == 0) { curViews.Add(rViewGUID, rView); } else { curViews[curViews.LastKey()] = rView; } break; default: break; } rView.Open(rOpenCompleted); }
public async Task <View> OpenPageUIAsync(string rViewName, View.State rState, Action <View> rOpenCompleted = null) { var rView = await ViewManager.Instance.OpenAsync(rViewName, rState, rOpenCompleted); if (rView != null && rView.IsBackCache) { this.mBackCaches.Push(new BackCache() { ViewName = rView.ViewName, ViewGUID = rView.GUID, State = rView.CurState, }); } return(rView); }
public void OpenPageUI(string rViewName, View.State rState, Action <View> rOpenCompleted = null) { ViewManager.Instance.Open(rViewName, rState, (rView) => { if (rView != null && rView.IsBackCache) { this.mBackCaches.Push(new BackCache() { ViewName = rView.ViewName, ViewGUID = rView.GUID, State = rView.CurState, }); } UtilTool.SafeExecute(rOpenCompleted, rView); }); }
/// <summary> /// 企图关闭一个当前的View,当存在当前View时候,并且传入的View是需要Dispatch的。 /// </summary> private void MaybeCloseTopView(View.State rViewState) { // 得到顶层结点 KeyValuePair <string, View> rTopNode = this.mCurViews.Last(); string rViewGUID = rTopNode.Key; View rView = rTopNode.Value; if (rView == null) { return; } if (rViewState == View.State.dispatch) { // 移除顶层结点 this.mCurViews.Remove(rViewGUID); rView.Close(); this.StartCoroutine(DestroyView_Async(rView)); } }
public Coroutine OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null) { return(this.StartCoroutine(Open_Async(rViewName, rViewState, rOpenCompleted))); }
/// <summary> /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换 /// </summary> public async Task <View> OpenView(string rViewName, GameObject rViewPrefab, View.State rViewState, ViewModel rViewModel, Action <View> rOpenCompleted) { if (rViewPrefab == null) { return(null); } //把View的GameObject结点加到rootCanvas下 GameObject rViewGo = null; switch (rViewState) { case View.State.Fixing: rViewGo = this.DynamicRoot.transform.AddChildNoScale(rViewPrefab, "UI"); break; case View.State.Popup: rViewGo = this.PopupRoot.transform.AddChildNoScale(rViewPrefab, "UI"); break; case View.State.Frame: rViewGo = this.FrameRoot.transform.AddChildNoScale(rViewPrefab, "UI"); break; case View.State.PageSwitch: case View.State.PageOverlap: rViewGo = this.PageRoot.transform.AddChildNoScale(rViewPrefab, "UI"); break; } var rView = View.CreateView(rViewGo); string rViewGUID = Guid.NewGuid().ToString(); //生成GUID if (rView == null) { Debug.LogErrorFormat("GameObject {0} is null.", rViewGo.name); UtilTool.SafeExecute(rOpenCompleted, null); return(null); } // 设置Default ViewModel rView.DefaultViewModel = rViewModel; //新的View的存储逻辑 switch (rViewState) { case View.State.Fixing: mCurFixedViews.Add(rViewGUID, rView); break; case View.State.Frame: mCurFrameViews.Add(rViewGUID, rView); break; case View.State.PageSwitch: if (mCurPageViews.Count == 0) { mCurPageViews.Add(rViewGUID, rView); } else { var rTopNode = this.mCurPageViews.Last(); mCurPageViews.Remove(rTopNode.Key); mCurPageViews.Add(rViewGUID, rView); } break; case View.State.PageOverlap: mCurPageViews.Add(rViewGUID, rView); break; case View.State.Popup: mCurPageViews.Add(rViewGUID, rView); break; default: break; } try { await rView.Initialize(rViewName, rViewGUID, rViewState); //为View的初始化设置 await rView.Open(); } catch (Exception e) { Debug.LogException(e); } UtilTool.SafeExecute(rOpenCompleted, rView); return(rView); }
private async Task <View> OpenViewAsync(string rViewName, View.State rViewState, ViewModel rViewModel, Action <View> rOpenCompleted) { var rLoaderRequest = UIAssetLoader.Instance.LoadUI(rViewName); return(await OpenView(rViewName, rLoaderRequest.ViewPrefabGo, rViewState, rViewModel, rOpenCompleted)); }
public void Open(string rViewName, View.State rViewState, ViewModel rViewModel, Action <View> rOpenCompleted = null) { this.OpenAsync(rViewName, rViewState, rViewModel, rOpenCompleted).WarpErrors(); }
private async Task Open_Async(string rViewName, View.State rViewState, Action <View> rOpenCompleted) { var rLoaderRequest = await Framework.WindUI.UIAssetLoader.Instance.LoadUI(rViewName); OpenView(rViewName, rLoaderRequest.ViewPrefabGo, rViewState, rOpenCompleted); }
public void Open(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null) { #pragma warning disable 4014 this.OpenAsync(rViewName, rViewState, rOpenCompleted); #pragma warning restore 4014 }