//---------------------------------------------------------------------------------------------------------------------------------------------- public static void AnimationLoop(Action <float> onAnimate, float duration = 1, float interval = UPS_20, Interpolation.Kind interpolationKind = Interpolation.Kind.Linear) { var startTime = Time.time; ConditionalCall(() => { var t = Time.time - startTime; t %= duration; onAnimate(Interpolation.Apply(interpolationKind, t / duration)); return(false); }, null, interval); }
public static void AnimationPingPong(string name, Action <float> onAnimate, float duration = 1, float interval = UPS_20, Interpolation.Kind interpolationKind = Interpolation.Kind.Linear) { var startTime = Time.time; ConditionalCall(name, () => { var t = Time.time - startTime; var i = (int)(t / duration); t %= duration; t = i % 2 == 0 ? t : duration - t; onAnimate(Interpolation.Apply(interpolationKind, t / duration)); return(false); }, null, interval); }
public static void Animation(string name, Action <float> onAnimate, float duration = 1, Action onDone = null, float interval = UPS_20, Interpolation.Kind interpolationKind = Interpolation.Kind.Linear) { var startTime = Time.time; ConditionalCall(name, () => { var t = Time.time - startTime; if (t >= duration) { onAnimate(1); return(true); } onAnimate(Interpolation.Apply(interpolationKind, t / duration)); return(false); }, onDone, interval); }