0
0
JSJason Storey
The IEnumerator interface has three methods:
The first method, Co_OverTime, takes two parameters: the duration of the animation and a function to be executed on each animation frame.
The second method, onTick, takes three parameters: the duration of the animation, the animation curve to use (if provided), and a boolean flag indicating whether the animation should start automatically on frame tick or not.
The last method, AnimationCurve, takes only one parameter: a curve to use for the animation.
Library: Animation
IEnumerator Co_OverTime(float duration, Action<float> onTick,AnimationCurve curve = null)
{
float timer = 0;
curve ??= AnimationCurve.EaseInOut(0, 0, 1, 1);
while (timer < 1)
{
timer += Time.deltaTime / duration;
onTick?.Invoke(curve.Evaluate(duration));
yield return null;
}
}