> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/magic-time-local-time-scale/magic-time-manager/magic-time-manager-scripting.md).

# Magic Time Manager Scripting

v1.0

The [**Magic Time Manager**](/magic-pig-games/magic-time-local-time-scale/magic-time-manager.md) acts as a hub for [`LocalTimeScale`](/magic-pig-games/magic-time-local-time-scale/local-time-scale.md) objects that will generally be accessed by multiple objects.

## Accessing a `LocalTimeScale` Object

The `TimeScale(string timeScaleName)` 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.

<pre class="language-csharp"><code class="lang-csharp">var globalTimeScale = MagicTimeManager.Instance.TimeScale("Global");
<strong>float timeScale = globalTimeScale.TimeScale;
</strong><strong>float deltaTime = globalTimeScale.DeltaTime;
</strong></code></pre>

## 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.

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