> 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

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);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/magic-time-local-time-scale/magic-time-manager/magic-time-manager-scripting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
