using UnityEngine; using UnityEngine.UI; namespace AlicizaX.AnimationFlow.Runtime { [Category("Animation")] public class GraphicAlphaTo : ActionNode { public float duration = 1f; public EaseType easyType; public Graphic target; public bool setFrom; public float from; public float to; protected float orgValue; protected float enterValue; public override void OnInit() { orgValue = target.color.a; } public override void OnReset() { target.color = new Color(target.color.r, target.color.g, target.color.b, orgValue); } public override void OnEnter() { if (setFrom) { target.color = new Color(target.color.r, target.color.g, target.color.b, from); } enterValue = target.color.a; } public override void OnUpdate(float dt) { float a = Easing.Ease(easyType, enterValue, to, elapsedTime / duration); target.color = new Color(target.color.r, target.color.g, target.color.b, a); } public override bool Valid() { return target != null && duration > 0; } public override float Duration() { return duration; } public override bool HasSubTitle() { return true; } public override string SubTitle() { return target != null ? target.name : null; } } }