2025-02-07 16:05:13 +08:00
|
|
|
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;
|
|
|
|
}
|
2025-03-14 17:37:57 +08:00
|
|
|
|
2025-02-07 16:05:13 +08:00
|
|
|
public override void OnEnter() {
|
|
|
|
if (setFrom) {
|
|
|
|
target.alpha = from;
|
|
|
|
}
|
2025-03-14 17:37:57 +08:00
|
|
|
|
|
|
|
if (Condition())
|
|
|
|
{
|
|
|
|
target.alpha = to;
|
|
|
|
}
|
2025-02-07 16:05:13 +08:00
|
|
|
enterValue = target.alpha;
|
2025-03-14 17:37:57 +08:00
|
|
|
|
2025-02-07 16:05:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnUpdate(float dt) {
|
|
|
|
target.alpha = Easing.Ease(easyType, enterValue, to, elapsedTime / duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Valid() {
|
2025-03-14 17:37:57 +08:00
|
|
|
return target != null;
|
2025-02-07 16:05:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override float Duration() {
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool HasSubTitle() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string SubTitle() {
|
|
|
|
return target != null ? target.name : null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|