#if HAVE_NODECANVAS using System; using UnityEngine; using ParadoxNotion.Design; using NodeCanvas.Framework; using Framework.Support; using CanvasGroup = UnityEngine.CanvasGroup; namespace Framework.UI { /// Fades a CanvasGroup (UGUI) in or out [Category("UI")] [Description("Fades a CanvasGroup (UGUI) in or out")] public class FadeCanvasGroupTask : ActionTask { /// Canvas group that will be faded [RequiredField] //public Canvas CanvasToFade; public BBParameter CanvasToFade; /// Duration of the action in seconds public float Length; /// How long the fade-in should take in seconds public float FadeInDuration; /// How long the fade-out should take in seconds public float FadeOutDuration; /// Provides a summary description for the task protected override string info { get { if(this.CanvasToFade == null) { return "Fade CanvasGroup"; } else { return "Fade " + this.CanvasToFade.name; } } } /// Called once when the action is executed protected override void OnExecute() { } /// /// Called every frame, if and while the action is running and until it ends /// protected override void OnUpdate() { if(this.CanvasToFade.value != null) { float opacity = InterpolationHelper.InterpolateFade( elapsedTime, this.Length, this.FadeInDuration, this.FadeOutDuration ); opacity *= opacity; this.CanvasToFade.value.alpha = opacity; } if(elapsedTime >= this.Length) { EndAction(); } } /// Called whenever the action ends due to any reason protected override void OnStop() { //cutscene.value.Stop(); } } } // namespace Framework.UI #endif // HAVE_NODECANVAS