/// <summary> /// closeUI /// </summary> public void Close() { IsShowed = false; UIGameObject.SetActive(false); OnDisable(); OnClose(); }
/// <summary> /// 带Window的UI初始化,初始化成功返回true /// </summary> public bool Init <T> (UIParam uiParam) where T : WindowBase, new() { param = uiParam; //根据path加载 var obj = Resources.Load <GameObject>(Path); if (obj is null) { return(false); } UIGameObject = obj; UICanvas = UIGameObject.AddComponent <Canvas>(); UIGameObject.AddComponent <CanvasGroup>(); UICanvas.renderMode = RenderMode.ScreenSpaceOverlay; //set UI name: UIGameObject.name = ID.ToString(); ResetTransform(); Window = new T(); Window?.Init(); return(true); }
/// <summary> /// showUI /// </summary> public void Show() { IsShowed = true; UIGameObject.SetActive(true); OnEnable(); OnShow(); }
/// <summary> /// 不带Window的UI初始化 /// </summary> public bool Init(UIParam uiParam) { param = uiParam; //#根据path加载,改成AssetsManager var obj = Resources.Load <GameObject>(Path); if (obj is null) { return(false); } UIGameObject = obj; UICanvas = UIGameObject.AddComponent <Canvas>(); UIGameObject.AddComponent <CanvasGroup>(); UICanvas.renderMode = RenderMode.ScreenSpaceOverlay; ResetTransform(); Window = UIGameObject.GetComponent <WindowBase>(); Window?.Init(); return(true); }