55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
![]() |
using UnityEngine;
|
||
|
|
||
|
namespace AlicizaX.AnimationFlow.Runtime {
|
||
|
[Category("Animation")]
|
||
|
public class CanvasGroupAlphaTo : ActionNode {
|
||
|
public float duration = 1f;
|
||
|
public EaseType easyType;
|
||
|
public CanvasGroup target;
|
||
|
public bool setFrom;
|
||
|
public float from;
|
||
|
public float to;
|
||
|
|
||
|
protected float orgValue;
|
||
|
protected float enterValue;
|
||
|
|
||
|
public override void OnInit()
|
||
|
{
|
||
|
orgValue = target.alpha;
|
||
|
}
|
||
|
|
||
|
public override void OnReset()
|
||
|
{
|
||
|
target.alpha = orgValue;
|
||
|
}
|
||
|
|
||
|
public override void OnEnter() {
|
||
|
if (setFrom) {
|
||
|
target.alpha = from;
|
||
|
}
|
||
|
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 && duration > 0;
|
||
|
}
|
||
|
|
||
|
public override float Duration() {
|
||
|
return duration;
|
||
|
}
|
||
|
|
||
|
public override bool HasSubTitle() {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public override string SubTitle() {
|
||
|
return target != null ? target.name : null;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|