Skip to main content

Timer

A class in Root.Township, the global namespace.

A small stopwatch over Time.realtimeSinceStartup that can be paused, resumed and topped up. Not a component; create it with new.

Constructors​

MemberWhat it is
Timer()Creates a Timer with default values.

Fields​

2 private and internal fields
MemberWhat it is
private float savedDurationSeconds counted by previous runs and Add calls.
private float startReal time the current run began, or -1 when stopped.

Properties​

MemberWhat it is
float Duration { get; }Total seconds counted so far, including the current run if the timer is going.

Methods​

MemberWhat it is
void Add(float seconds)Adds the given seconds to the stored duration.
void Start()Starts or resumes counting. Does nothing if already running.
void Stop()Pauses counting and folds the current run into the stored duration.
void StopAndReset()Stops the timer and sets the duration back to zero.