Updated: 2018-09-06

A global singleton tasked with keeping track of global clocks in the scene. One and only one Timekeeper is required per scene.

The Timekeeper class follows the singleton design pattern. That's a complicated way of saying it's an object that can and must exist only once per scene. This object, called the instance, can be accessed from anywhere via Timekeeper.instance.


bool debug { get; set; }

Determines whether Chronos should display debug messages and gizmos in the editor.

int maxParticleLoops { get; set; }

The maximum loops during which particle systems should be allowed to run before resetting.

This property is a temporary performance hotfix until a better solution to particle simulation is found. You can set it to 0 or less for infinite loops, but expect some performance problems.


IEnumerable<GlobalClock> clocks { get; }

An enumeration of all the global clocks on the timekeeper.

bool HasClock(string key)

Indicates whether the timekeeper has a global clock with the specified key.

GlobalClock Clock(string key)

Returns the global clock with the specified key.

GlobalClock AddClock(string key)

Adds a global clock with the specified key and returns it.

void RemoveClock(string key)

Removes the global clock with the specified key.


Speed up the "Monsters" global clock if it exists:

if (Timekeeper.instance.HasClock("Monsters"))
	Timekeeper.instance.Clock("Monsters").localTimeScale = 2;

Create a new clock for enemies and apply it to all Enemy GameObjects:

Clock enemiesClock = Timekeeper.instance.AddClock("Enemies");
Enemy[] enemies = GameObject.FindObjectsOfType<Enemy>();

foreach (Enemy enemy in enemies)
	// This assumes every enemy already has a Timeline component
	Timeline timeline = enemy.GetComponent<Timeline>();
	timeline.mode = TimelineMode.Global;
	timeline.globalClockKey = enemiesClock.key;
Was this article helpful?
Be the first to vote!
Yes, helpful
No, not for me