public static int PushWindowOrder(this UILayer self) { var cur = self.top_window_order; self.top_window_order -= UIManagerComponent.Instance.MaxOderPerWindow; return(cur); }
public static void SetTopOrderInLayer(this UILayer self, int order) { if (self.top_window_order < order) { self.top_window_order = order; } }
public static async ETTask <UI> Create(this UIComponent self, string uiType, UILayer uiLayer) { UI ui = await UIEventComponent.Instance.OnCreate(self, uiType, uiLayer); self.UIs.Add(uiType, ui); return(ui); }
public void Add(FGUI ui, UILayer layer = UILayer.Mid, bool asChildGObject = true) { var layerUI = Root?.Get(layer.ToString()); if (layerUI != null) { layerUI.Add(ui, asChildGObject); } }
//设置canvas的worldCamera public static void SetCanvasWorldCamera(this UILayer self, Camera camera) { var old_camera = self.unity_canvas.worldCamera; if (old_camera != camera) { self.unity_canvas.worldCamera = camera; } }
public override async ETTask <UI> OnCreate(UIComponent uiComponent, UILayer uiLayer) { await uiComponent.Domain.GetComponent <ResourcesLoaderComponent>().LoadAsync(UIType.UILogin.StringToAB()); GameObject bundleGameObject = (GameObject)ResourcesComponent.Instance.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject, UIEventComponent.Instance.UILayers[(int)uiLayer]); UI ui = uiComponent.AddChild <UI, string, GameObject>(UIType.UILogin, gameObject); ui.AddComponent <UILoginComponent>(); return(ui); }
/// <summary> /// editor调整canvas scale /// </summary> /// <param name="flag">是否竖屏</param> public static void SetCanvasScaleEditorPortrait(this UILayer self, bool flag) { if (flag) { self.unity_canvas_scaler.referenceResolution = new Vector2(Define.DesignScreen_Height, Define.DesignScreen_Width); self.unity_canvas_scaler.matchWidthOrHeight = 0; } else { self.unity_canvas_scaler.referenceResolution = UIManagerComponent.Instance.GetComponent <UILayersComponent>().Resolution; self.unity_canvas_scaler.matchWidthOrHeight = 1; } }
/*public FGUI[] GetAll() * { * return * }*/ public void Clear(UILayer layer = UILayer.All) { if (layer == UILayer.All) { for (int i = 0; i < (int)UILayer.All; i++) { Clear((UILayer)i); } } else { Root?.Get(layer.ToString()).RemoveChildren(); } }
public static async ETTask <UI> OnCreate(this UIEventComponent self, UIComponent uiComponent, string uiType) { try { UI ui = await self.UIEvents[uiType].OnCreate(uiComponent); UILayer uiLayer = (ui.GameObject.GetComponent(typeof(UILayerScript)) as UILayerScript).UILayer; ui.GameObject.transform.SetParent(self.UILayers[(int)uiLayer]); return(ui); } catch (Exception e) { throw new Exception($"on create ui error: {uiType}", e); } }
public void Remove(string name, UILayer layer = UILayer.All) { if (layer == UILayer.All) { for (int i = 0; i < (int)UILayer.All; i++) { Remove(name, (UILayer)i); } } else { var UIlayer = Root?.Get(layer.ToString()); UIlayer?.Remove(name); } }
public override async ETTask <UI> OnCreate(UIComponent uiComponent, UILayer uiLayer) { try { await ETTask.CompletedTask; GameObject bundleGameObject = ((GameObject)Resources.Load("KV")).Get <GameObject>(UIType.UILoading); GameObject go = UnityEngine.Object.Instantiate(bundleGameObject); go.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = uiComponent.AddChild <UI, string, GameObject>(UIType.UILoading, go); ui.AddComponent <UILoadingComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public FGUI Get(string name, UILayer layer = UILayer.All) { if (layer == UILayer.All) { for (int i = 0; i < (int)UILayer.All; i++) { var l = Get(name, (UILayer)i); if (l != null) { return(l); } } } else { var UIlayer = Root?.Get(layer.ToString()); return(UIlayer?.Get(name)); } return(null); }
public override void Awake(UILayersComponent self) { Log.Info("UILayersComponent Awake"); UILayersComponent.Instance = self; self.UIRootPath = "Global/UI"; self.EventSystemPath = "EventSystem"; self.UICameraPath = self.UIRootPath + "/UICamera"; self.gameObject = GameObject.Find(self.UIRootPath); var event_system = GameObject.Find(self.EventSystemPath); var transform = self.gameObject.transform; self.UICamera = GameObject.Find(self.UICameraPath).GetComponent <Camera>(); GameObject.DontDestroyOnLoad(self.gameObject); GameObject.DontDestroyOnLoad(event_system); self.Resolution = new Vector2(Define.DesignScreen_Width, Define.DesignScreen_Height); //分辨率 self.layers = new Dictionary <UILayerNames, UILayer>(); var UILayers = GetConfig(); for (int i = 0; i < UILayers.Length; i++) { var layer = UILayers[i]; var go = new GameObject(layer.Name.ToString()) { layer = 5 }; var trans = go.transform; trans.SetParent(transform, false); UILayer new_layer = self.AddChild <UILayer, UILayerDefine, GameObject>(layer, go); self.layers[layer.Name] = new_layer; UIManagerComponent.Instance.window_stack[layer.Name] = new LinkedList <string>(); } var flagx = (float)Define.DesignScreen_Width / (Screen.width > Screen.height ? Screen.width : Screen.height); var flagy = (float)Define.DesignScreen_Height / (Screen.width > Screen.height ? Screen.height : Screen.width); UIManagerComponent.Instance.ScreenSizeflag = flagx > flagy ? flagx : flagy; }
public static async ETTask <UI> OnCreate(this UIEventComponent self, UIComponent uiComponent, string uiType, UILayer uiLayer) { try { UI ui = await self.UIEvents[uiType].OnCreate(uiComponent, uiLayer); return(ui); } catch (Exception e) { throw new Exception($"on create ui error: {uiType}", e); } }
public static int GetMinOrderInLayer(this UILayer self) { return(self.min_window_order); }
public static Vector2 GetCanvasSize(this UILayer self) { return(self.rectTransform.rect.size); }
public static int GetTopOrderInLayer(this UILayer self) { return(self.top_window_order); }
public static int GetCanvasLayer(this UILayer self) { return(self.transform.gameObject.layer); }