Skip to main content

AnimateProgress

A class in Root.Township, the global namespace.

Animates a value from 0 to 1 over a set time and passes it to a FloatEvent each frame, for driving UI or effects from inspector events.

Constructors​

MemberWhat it is
AnimateProgress()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private float durationSeconds the 0 to 1 animation takes.
private float progressCurrent progress, 0 to 1.
private FloatEvent progressUpdateEvent invoked with the progress every step.
private bool resetsOnLoopIf true, calling Animate after it finished starts again from 0.
private IUnityUpdateMethod updateHandle for the registered update method.

Methods​

MemberWhat it is
void Animate()Starts (or restarts) the per-frame update; resets to 0 first if resetsOnLoop is set and it had finished.
void Reset()Sets progress back to 0 and fires the event with 0.
2 private and internal methods
MemberWhat it is
private void OnDestroy()Deregisters the update.
private void UpdateProgress()Per-frame step: adds delta time over duration, clamps at 1 and stops there, then fires the event.