Magic Time Manager
v1.0
Create an empty object, perhaps named "Magic Time Manager", and add the MagicTimeManager
component onto it. This holds LocalTimeScale
instances which can be accessed by any IUseMagicTime
(or MagicTimeUser
) object.
![](https://infinitypbr.gitbook.io/~gitbook/image?url=https%3A%2F%2F2431624982-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MY3N_li2jPq7az6mYfq%252Fuploads%252FNU1LgMfCz8ZvZccuhvkr%252FScreenshot%25202024-09-15%2520at%25207.34.09%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3Ded94d9f1-1a30-43c6-a6f0-570e29663de2&width=768&dpr=4&quality=100&sign=7e41bcda&sv=2)
Initial Time Scales
Populate this list with Local Time Scale Scriptable Objects you've created. Each will be replaced with a new instance of those objects, to keep from overwriting the default values on the Scriptable Objects.
In Game TimeScales
At runtime, information about each LocalTimeScale
will be shown here, including the current value and the number of subscribers.
![](https://infinitypbr.gitbook.io/~gitbook/image?url=https%3A%2F%2F2431624982-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MY3N_li2jPq7az6mYfq%252Fuploads%252Ffm12fvY6s1JFjp233As4%252FScreenshot%25202024-09-15%2520at%25207.10.54%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D8cedd12b-5f8e-4de9-9414-2585112d26a0&width=768&dpr=4&quality=100&sign=9c7246ca&sv=2)
Other objects which inherit from MagicTimeUser
or implement IUseMagicTime
can "Subscribe to Initial TimeScales". When this happens, they subscribe to the instance assigned to the Magic Time Manager.
This way, all objects will be following the same instance, and share the same information.
All Time Scales
This List<LocalTimeScale>
is populated automatically when you view the Magic Time Manager in the Inspector. It contains all of the Scriptable Objects in the project, so you can easily find them.
This is also used when the TimeScale()
method is called -- if the LocalTimeScale
has not been instanced yet, then the script will look it up in this list, before trying to create a new LocalTimeScale
object.
Additional Scripting
Don't forget to check out the Magic Time Manager Scripting page for more information on what you can do with this class.
Magic Time Manager ScriptingLast updated
Was this helpful?