protected bool PopNavigationWindow() { #region 导航信息为空 if (backSequence.Count == 0) { if (curNavigationWindow == null) { return(false); } //如果当前navigation的栈是空, 就检查当前UI的配置PrewindowID, 打开 WindowID preWindowId = curNavigationWindow.UIConfigData.PreWindowId; if (preWindowId != WindowID.WindowID_Invaild) { Debug.LogWarning(string.Format(string.Format("## Current nav window {0} need show pre window {1}.", curNavigationWindow.ID.ToString(), preWindowId.ToString()))); HideWindow(curNavigationWindow.ID, delegate { //不执行导航 WindowContextDataBase showData = new WindowContextDataBase(); showData.executeNavLogic = false; ShowWindow(preWindowId, showData); }); } else { Debug.LogWarning("## CurrentShownWindow " + curNavigationWindow.ID + " preWindowId is " + WindowID.WindowID_Invaild); } return(false); } #endregion NavigationData backData = backSequence.Peek(); if (backData != null) { // check the current navigation data int curId = this.GetCurrentShownWindow(); if (curId != (int)backData.showingUI.ID) { Debug.Log("<color=red>当前导航Stack里面信息不对 [backData.showingUI.ID != this.curShownWindowId]</color>"); return(false); } //关闭当前的UI, 恢复显示stack里面保存的UI WindowID showingId = backData.showingUI.ID; if (!dicShownWindows.ContainsKey((int)showingId)) { PopNavigationUI(backData); } else { HideWindow(showingId, delegate { PopNavigationUI(backData); }); } } return(true); }
public void ShowWindow(WindowID id, WindowContextDataBase showContextData = null) { UIControllerBase baseWindow = PrepareUI(id, showContextData); if (baseWindow != null) { Show(baseWindow, id, showContextData); } }
private void Show(UIControllerBase baseWindow, WindowID id, WindowContextDataBase contextData = null) { baseWindow.ShowWindow(contextData); dicShownWindows[(int)id] = baseWindow; if (baseWindow.UIConfigData.navigationMode == UIWindowNavigationMode.NormalNavigation) { lastNavigationWindow = curNavigationWindow; curNavigationWindow = baseWindow; Debug.Log("<color=magenta>### current Navigation window </color>" + baseWindow.ID.ToString()); } }
public void ShowWindow(WindowContextDataBase contextData = null) { if (baseView == null) { return; } baseView.SetActive(true); IsActive = true; IsLoading = true; IsExiting = false; OnUIOpened(); //处理动画 DoEnteringAnimation(OnEnteringAnimationEnd); // this.RegisterReturnLogic(this.RetrunPreLogic); }
private UIControllerBase PrepareUI(WindowID id, WindowContextDataBase showContextData = null) { if (!this.IsWindowRegistered(id)) { return(null); } if (dicShownWindows.ContainsKey((int)id)) { return(null); } UIControllerBase baseController = GetGameWindowFromCache(id); //UI没有在场景里打开过, Instantiate New One bool newAdded = false; if (baseController == null) { newAdded = true; if (UIResourceDefine.windowPrefabPath.ContainsKey((int)id)) { //实例化UI UIViewBase uiView = GameUIUtility.InstantiateUI(id); //保存Controller baseController = uiView.Controller; dicWindowsCache[(int)id] = baseController; //初始化 baseController.OnInit(); //设置UI根 Transform targetRoot = GameUIUtility.GetUIRoot();//UINormalWindowRoot; GameUIUtility.AddChildToTarget(targetRoot, uiView.gameObject.transform); //设置UI Camera Canvas uiCanvas = uiView.gameObject.GetComponent <Canvas>(); uiCanvas.renderMode = RenderMode.ScreenSpaceCamera; { GameObject uiCamera = GameObject.Find("UICamera"); if (uiCamera != null) { uiCanvas.worldCamera = uiCamera.GetComponent <Camera>(); } } //添加通用背景 AddColliderBgForWindow(uiView); } else { Debug.LogError("UI ID对应的Prefab位置在找不到, 使用工具重新生成 " + id); return(null); } } if (baseController == null) { Debug.LogError("[UI instance is null.]" + id.ToString()); } //设置导航信息, 如果是导航类型的UI会把当前显示的UI关闭并且保存到BackSequenceStack里面 //下次返回的时候, 从Stack里面回复. if (showContextData == null || (showContextData != null && showContextData.executeNavLogic)) { ExecuteNavigationLogic(baseController); } //层级管理 //AdjustBaseWindowDepth(baseController); return(baseController); }