com.alicizax.unity.animatio.../Runtime/Core/Animation/CanvasGroupAlphaTo.cs

62 lines
1.2 KiB
C#

using UnityEngine;
namespace AlicizaX.AnimationFlow.Runtime
{
[Category("Animation")]
public class CanvasGroupAlphaTo : AnimationBaseNode<float>
{
[SerializeField]
private CanvasGroup _target;
public override void OnInit()
{
orgValue = _target.alpha;
}
public override void OnReset()
{
_target.alpha = orgValue;
}
public override void OnEnter()
{
if (setFrom)
{
_target.alpha = from;
}
if (Condition())
{
_target.alpha = to;
}
enterValue = _target.alpha;
}
public override void OnUpdate(float dt)
{
_target.alpha = Easing.Ease(easyType, enterValue, to, elapsedTime / duration);
}
public override bool Valid()
{
return _target != null;
}
public override float Duration()
{
return duration;
}
public override bool HasSubTitle()
{
return true;
}
public override string SubTitle()
{
return _target != null ? _target.name : null;
}
}
}