using UnityEngine; namespace Core.UI { /// /// Abstract base class for menu pages which animates the process of enabling and disabling /// Handles activation/deactivation of the page /// public abstract class AnimatingMainMenuPage : MonoBehaviour, IMainMenuPage { /// /// Canvas to disable. If this object is set, then the canvas is disabled instead of the game object /// public Canvas canvas; /// /// Deactivates this page /// public virtual void Hide() { BeginDeactivatingPage(); } /// /// Activates this page /// public virtual void Show() { BeginActivatingPage(); } /// /// Starts the deactivation process. e.g. begins fading page out. Call FinishedDeactivatingPage when done /// protected abstract void BeginDeactivatingPage(); /// /// Ends the deactivation process and turns off the associated gameObject/canvas /// protected virtual void FinishedDeactivatingPage() { if (canvas != null) { canvas.enabled = false; } else { gameObject.SetActive(false); } } /// /// Starts the activation process by turning on the associated gameObject/canvas. Call FinishedActivatingPage when done /// protected virtual void BeginActivatingPage() { if (canvas != null) { canvas.enabled = true; } else { gameObject.SetActive(true); } } /// /// Finishes the activation process. e.g. Turning on input /// protected abstract void FinishedActivatingPage(); } }