public void ReturnBackWithCurrentUIManager(string targetWindow, Action onFinished) { if (CurrentUIManager) { CurrentUIManager.ReturnBack(targetWindow, onFinished); } }
public void ReturnBackWithCurrentUIManager(int depth, Action onFinished) { if (CurrentUIManager) { CurrentUIManager.ReturnBack(depth, onFinished); } }
public void ShowWindowWithCurrentUIManager(string targetWindowName, object[] args = null, Action onFinished = null, bool isShowLoading = false, bool isDestroy = false, bool isHideFormer = false) { if (CurrentUIManager) { CurrentUIManager.ShowWindow(targetWindowName, args, onFinished, isShowLoading, isDestroy, isHideFormer); } }
/// <summary> /// 返回界面,如果depth不合法,则销毁栈里所界面,并跳转到大厅界面。 /// </summary> /// <param name="depth"></param> /// <param name="onFinished"></param> public void ReturnBack(int depth, Action onFinished, string fromWindow = "") { //栈里没有窗体,错误的调用“ReturnBack”的情况。 if (_uiWindows.Count <= 0) { LogUtil.LogError("ReturnBack错误!!!栈里没有界面!!!"); return; } if (depth <= 0) { LogUtil.LogError(string.Format("返回深度错误,depth = {0},depth应为大于0的整数!", depth)); } //如果返回 depth 层级后,栈里将没有窗体,为了避免出错,此情况默认返回到主界面 if (_uiWindows.Count <= depth) { LogUtil.LogError(string.Format("ReturnBack错误!!!depth不合法,如果返回{0}层,栈里将没有界面!!!", depth)); //LogUtil.LogError(string.Format("ReturnBack错误!!!depth不合法,如果返回{0}层,栈里将没有界面!!!此情况默认返回到大厅界面!!!", depth)); ////此处必须全部出栈,然后跳转窗口到大厅界面。 ////eg:断线重连的情况,未加载大厅界面,如果游戏界面错误调用“ReturnBack”,则需要全部出栈,并跳转窗口到大厅界面。 //while (_uiWindows.Count > 0) //{ // var window = _uiWindows.Pop(); // window.WindowObj.SetActive(false); // Destroy(window.WindowObj); //} //ChangeWindow(string.Empty, "ui_win_hall"); return; } //出栈并销毁depth层窗体 //三个bool值用于返回到目标界面时,目标界面数据更新 bool isChangeWindow = false; //eg:因为“ChangeWindow”默认隐藏了之前的窗体,ChangeWindow 为 true 时,重新选中默认物体 bool isShowLoading = false; //eg:因为“isShowLoading”显示了加载界面,isShowLoading 为 true 时,显示loading界面 bool isHideFormer = false; //eg:因为“isHideFormer”隐藏了之前的窗体,isHideFormer 为 true 时,显示目标界面 for (int i = 0; i < depth; i++) { UIWindow uiWindow = _uiWindows.Pop(); ObjectCache.instance.ClearGroup(uiWindow.MUIManager.name); if (i == depth - 1) { isChangeWindow = uiWindow.IsChangeWindow; isShowLoading = uiWindow.IsShowLoading; isHideFormer = uiWindow.IsHideFormer; } uiWindow.WindowObj.SetActive(false);//因为Destroy是在FixedUpdate执行,所以先SetActive false Destroy(uiWindow.WindowObj); } //回复当前窗体所有可交互组件的交互性 UIWindow curWindow = _uiWindows.Peek(); Util.EnableWindowSelectable(curWindow.WindowObj, true); LogUtil.Log(string.Format("成功从界面“{0}”返回界面“{1}”", fromWindow, curWindow.WindowName)); if (isHideFormer) { curWindow.WindowObj.SetActive(true); } if (isShowLoading)//ChangeWindow 跳转窗口 { ShowLodingWindow(() => { CurrentUIManager.ReturnBackToThisWindow(true); if (onFinished != null) { onFinished(); } }); } else { CurrentUIManager.ReturnBackToThisWindow(isChangeWindow); if (onFinished != null) { onFinished(); } } }