protected virtual void OnDisable() { if (Application.isPlaying && this.m_UseBlackOverlay) { UIBlackOverlay overlay = UIBlackOverlay.GetOverlay(this.gameObject); if (overlay != null) { this.onTransitionBegin.RemoveListener(overlay.OnTransitionBegin); } } }
/// <summary> /// Gets the black overlay based on relative game object. (In case we have multiple canvases.) /// </summary> /// <param name="relativeGameObject">The relative game object.</param> /// <returns>The black overlay component.</returns> public static UIBlackOverlay GetOverlay(GameObject relativeGameObject) { // Find the black overlay in the current canvas Canvas canvas = UIUtility.FindInParents <Canvas>(relativeGameObject); if (canvas != null) { // Try finding an overlay in the canvas UIBlackOverlay overlay = canvas.gameObject.GetComponentInChildren <UIBlackOverlay>(); if (overlay != null) { return(overlay); } // In case no overlay is found instantiate one if (UIBlackOverlayManager.Instance != null && UIBlackOverlayManager.Instance.prefab != null) { return(UIBlackOverlayManager.Instance.Create(canvas.transform)); } } return(null); }