Magic Time Manager Scripting

v1.0

The Magic Time Manager acts as a hub for LocalTimeScale objects that will generally be accessed by multiple objects.

Accessing a LocalTimeScale Object

The TimeScale() method will return the LocalTimeScale instance based on the name provided in the signature. By default, this method will also add a new instance of the LocalTimeScale if it is not yet found.

When the Local Time Scale is not found, the script will look for it in the list of all Scriptable Objects in the project. If it is found there, a new instance will be created, which you can then reference from any Magic Time User object.

If there is no existing Scriptable Object found, a new LocalTimeScale object will be created. By default the default value will be 1f, but you can set this to whatever you'd like in the signature.

var globalTimeScale = MagicTimeManager.Instance.TimeScale("Global");
float timeScale = globalTimeScale.TimeScale;
float deltaTime = globalTimeScale.DeltaTime;

Removing a LocalTimeScale

The RemoveTimeScale() method will first unsubscribe all subscribers from the list, and then destroy the object.

Clone a LocalTimeScale

You can get a deep copy of a LocalTimeScale object using this method. Note that the copy will not be added to the list of all time scales, nor will it be accessible via the TimeScale() method. It can be used in other ways, of course.

var globalTimeScale = MagicTimeManager.Instance.TimeScale("Global");
var copyOfGlobalTimeScale = MagicTimeManager.CloneTimeScale(globalTimeScale);

Last updated