public static async ETTask CloseWindowByLayer(this UIManagerComponent self, UILayerNames layer, params string[] except_ui_names) { Dictionary <string, bool> dict_ui_names = null; if (except_ui_names != null && except_ui_names.Length > 0) { dict_ui_names = new Dictionary <string, bool>(); for (int i = 0; i < except_ui_names.Length; i++) { dict_ui_names[except_ui_names[i]] = true; } } using (ListComponent <ETTask> TaskScheduler = ListComponent <ETTask> .Create()) { foreach (var item in self.windows) { if (item.Value.Layer == layer && (dict_ui_names == null || !dict_ui_names.ContainsKey(item.Key))) { TaskScheduler.Add(self.CloseWindow(item.Key)); } } await ETTaskHelper.WaitAll(TaskScheduler); } }
public static UILayer GetLayer(this UIManagerComponent self, UILayerNames layer) { if (UILayersComponent.Instance.layers.TryGetValue(layer, out var res)) { return(res); } return(null); }
/// <summary> /// 初始化window /// </summary> static UIWindow __InitWindow <T>(this UIManagerComponent self, string path, UILayerNames layer_name) where T : Entity, IAwake, new() { UIWindow window = self.AddChild <UIWindow>(); var type = typeof(T); window.Name = type.Name; window.Active = false; window.ViewType = type; window.Layer = layer_name; window.LoadingState = UIWindowLoadingState.NotStart; window.PrefabPath = path; window.AddComponent <T>(); return(window); }
//打开窗口 public static async ETTask <T> OpenWindow <T, P1, P2, P3, P4>(this UIManagerComponent self, string path, P1 p1, P2 p2, P3 p3, P4 p4, UILayerNames layer_name = UILayerNames.NormalLayer, bool banKey = true) where T : Entity, IAwake, IOnCreate, IOnEnable <P1, P2, P3, P4>, new() { string ui_name = typeof(T).Name; var target = self.GetWindow(ui_name); if (target == null) { target = self.__InitWindow <T>(path, layer_name); self.windows[ui_name] = target; } target.Layer = layer_name; target.BanKey = banKey; return(await self.__InnerOpenWindow <T, P1, P2, P3, P4>(target, p1, p2, p3, p4)); }
//销毁层级所有窗口 public static async ETTask DestroyWindowByLayer(this UIManagerComponent self, UILayerNames layer) { var keys = self.windows.Keys.ToArray(); using (ListComponent <ETTask> TaskScheduler = ListComponent <ETTask> .Create()) { for (int i = self.windows.Count - 1; i >= 0; i--) { if (self.windows[keys[i]].Layer == layer) { TaskScheduler.Add(self.DestroyWindow(self.windows[keys[i]].Name)); } } await ETTaskHelper.WaitAll(TaskScheduler); } }
//打开窗口 public static async ETTask OpenWindowTask <T, P1, P2, P3, P4>(this UIManagerComponent self, string path, P1 p1, P2 p2, P3 p3, P4 p4, UILayerNames layer_name = UILayerNames.NormalLayer) where T : Entity, IAwake, IOnCreate, IOnEnable <P1, P2, P3, P4>, new() { await self.OpenWindow <T, P1, P2, P3, P4>(path, p1, p2, p3, p4, layer_name); }
//打开窗口 public static async ETTask OpenWindowTask <T>(this UIManagerComponent self, string path, UILayerNames layer_name = UILayerNames.NormalLayer) where T : Entity, IAwake, IOnCreate, IOnEnable, new() { await self.OpenWindow <T>(path, layer_name); }