using UnityEngine; using UnityEngine.Events; [CreateAssetMenu(menuName = "Events/UI/Fade Channel")] public class FadeChannelSO : ScriptableObject { public UnityAction OnEventRaised; /// /// Fade helper function to simplify usage. Fades the screen in to gameplay. /// /// How long it takes to the image to fade in. /// Target color for the image to reach. public void FadeIn(float duration) { Fade(true, duration, Color.clear); } /// /// Fade helper function to simplify usage. Fades the screen out to black. /// /// How long it takes to the image to fade out. public void FadeOut(float duration) { Fade(false, duration, Color.black); } /// /// Generic fade function. Communicates with . /// /// If true, the rectangle fades in. If false, the rectangle fades out. /// How long it takes to the image to fade in/out. /// Target color for the image to reach. Disregarded when fading out. private void Fade(bool fadeIn, float duration, Color color) { if (OnEventRaised != null) OnEventRaised.Invoke(fadeIn, duration, color); } }