Skip to main content

TimedEvent

A class in Root.Township, the global namespace.

A plain component that fires a TransformEvent once, or every interval seconds when repeating. Runs locally on whichever side has it, with no networking or saving.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private bool btnPlayInspector button that calls Begin from OnValidate.
private bool btnStopInspector button that calls Stop from OnValidate.
private float intervalSeconds between repeats. Only shown when isRepeating is ticked.
private bool isRepeatingWhen true, Begin keeps firing every interval seconds instead of once.
private bool isRunningOnAwakeWhen true, Begin is called in Awake.
private Coroutine repeatThe running repeat coroutine, or null.
private TransformEvent runHereEvent invoked with this object's transform each time the timer fires.

Methods​

MemberWhat it is
void Begin()Fires runHere once, or starts the repeat coroutine when isRepeating is set (restarting it if already running).
void Stop()Stops the repeat coroutine if one is running.
3 private and internal methods
MemberWhat it is
private void Awake()Stops any running repeat, then calls Begin if isRunningOnAwake is set.
private void OnValidate()Editor hook: ticking the Play or Stop inspector buttons calls Begin or Stop.
private IEnumerator RepeatRun() (iterator)Coroutine that invokes runHere with this transform, then waits interval seconds, forever.