//保存创建的弹窗引用 public static void TryCacheUIPopWindow(UIBasePopWindow popWindow) { if (s_AllAcivityPopWIndows.TryGetValue(popWindow.PageName, out var allBasePopWindows) == false) { allBasePopWindows = new List <UIBasePopWindow>(); s_AllAcivityPopWIndows[popWindow.PageName] = allBasePopWindows; } allBasePopWindows.Add(popWindow); }
/// <summary>/// 隐藏一个弹窗 有可能有多个同名的窗口 所以这里不提供关闭弹窗的接口 /// </summary> public static void HidePopwindow(string pageName, bool isForceDestroyed = false) { if (string.IsNullOrEmpty(pageName)) { Debug.LogError("HidePopWindow Fail, parameter id null"); return; } UIBasePopWindow target = TryGetUIPopWindowFromCache(pageName, 1); HidePopwindow(target, isForceDestroyed); }
/// <summary>/// 只在弹窗被真正销毁时候调用/// </summary> public static void RemoveUIPopWindowFromCache(UIBasePopWindow popWindow) { if (s_AllAcivityPopWIndows.TryGetValue(popWindow.PageName, out var allBasePopWindows)) { if (allBasePopWindows == null || allBasePopWindows.Count == 0) { return; } for (int dIndex = allBasePopWindows.Count - 1; dIndex >= 0; dIndex--) { if (allBasePopWindows[dIndex] == popWindow) { allBasePopWindows.RemoveAt(dIndex); return; } } } }
/// <summary>/// 隐藏一个弹窗/// </summary> public static void HidePopwindow(UIBasePopWindow popWindow, bool isForceDestroyed = false) { if (popWindow == null) { Debug.LogError("HidePopWindow Fail,parameter is null"); return; } if (popWindow.mIsActivite == false) { #if UNITY_EDITOR Debug.LogError($"HidePopWindow Fail, 弹窗 {popWindow.PageName} 已经关闭了"); #endif return; } string previousPageName = popWindow.PageName; popWindow.HidePage(isForceDestroyed); EventManager.TriggerMessage((int)UIEventUsage.NotifyHidePopWindow, popWindow); //关闭弹窗 }