public void Init() { OnActivated += new Activated(PageActivatedHandler); OnDeActivated += new DeActivated(PageDeActivatedHandler); if (rt == null) { rt = GetComponent <RectTransform>(); } if (AssetBundleRequired) { //TODO:Maybe extend this to handle missing asset bundles } rt.sizeDelta = new Vector2(UIB_AspectRatioManager.ScreenWidth, UIB_AspectRatioManager.ScreenHeight); //assign the close_button //gameobject must be named close_button and be a child of this gameobject foreach (UnityEngine.UI.Button b in GetComponentsInChildren <UnityEngine.UI.Button>()) { if (b.gameObject.name.Equals("close_button")) { close_button = b; } } if (close_button != null) { close_button.onClick.AddListener(DeActivate); } else { //Debug.LogWarning(gameObject.name + ": You need to create a button named \"close_button\" as a child of this gameobject, otherwise the screen will never be closed"); } #region Views //TODO: Someday i'll re-make the view system #endregion page_Canvas = gameObject.GetComponent <Canvas>(); if (page_Canvas == null) { Debug.LogWarning("no canvas on this object " + name); } else { page_Canvas.enabled = false; } }
//TODO: Comment the heck out of this public void Init() { //Set page to handle swipe input UIB_InputManager.SwipeDelegate += SwipeHandler; if (PagesOnScreen == null) { PagesOnScreen = new List <Transform>(); } //Register for onactivated and on deactivated handlers OnActivated += new Activated(PageActivatedHandler); OnDeActivated += new DeActivated(PageDeActivatedHandler); //Set rect transform if (rt == null) { rt = GetComponent <RectTransform>(); } if (AssetBundleRequired) { //TODO:Maybe extend this to handle missing asset bundles } //Set size of transform if (resolution == null) { resolution = Resources.Load("ScriptableObjects/ResolutionAsset") as Resolution; } rt.sizeDelta = new Vector2(resolution.Width, resolution.Height); #region Views //TODO: Someday i'll re-make the view system #endregion //Ensure object contains a canvas page_Canvas = gameObject.GetComponent <Canvas>(); if (page_Canvas == null) { Debug.LogWarning("no canvas on this object " + name); } else { page_Canvas.enabled = true; //activate the canvas } }
protected virtual void OnDisable() { DeActivated?.Invoke(); }