> ## Documentation Index
> Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
> Use this file to discover all available pages before exploring further.

# GameManager

> Cross-scene subsystem for HTTP error UX and global game hooks.

**File:** `Assets/_MolcaSDK/Code/Scripts/GameManager.cs`\
**Namespace:** `MolcaSDK`\
**Type:** [RuntimeSubsystem](/core/runtime-subsystem) (child on [RuntimeManager](/core/runtime-manager) prefab)

## When to use

Use **`GameManager`** when you want **global handling of HTTP connection errors** from [HttpClient](/core/http-client): one place to show a localized **connection failure** modal instead of teaching every screen to catch **`OnConnectionError`**. It does not replace scene bootstrapping — only connection UX.

## Role

Sets **`Instance`** during **`Initialize`**, subscribes to **`HttpClient.OnConnectionError`**, and when **`enableConnectionFailConfirmation`** is on, pushes the error string into **`ModalConfirmationHelper`** (default language via **`LocalizationManager.DefaultLanguageCode`**) after a short delay.

## Code

```csharp theme={null}
using MolcaSDK;
using UnityEngine;

public class PauseMenu : MonoBehaviour
{
    public void OpenSettings()
    {
        var gm = GameManager.Instance;
        if (gm == null) return;
        // Read flags or call your flows; connection error UX is configured on the component
    }
}
```

Use **`GameManager.Instance`** only after **`RuntimeManager`** has finished subsystem initialization. Calling **`Instance`** before init logs **"GameManager is not initialized!"** and still returns null reference behavior risk — prefer **`RuntimeManager.GetSubsystem<GameManager>()`** if you need a safe null check.

## Troubleshooting

* **Modal never appears** — Enable **`enableConnectionFailConfirmation`**, assign **`connectionFailConfirmation`**, and confirm **`HttpClient`** actually raises **`OnConnectionError`** for your failure (some paths may only set response flags).
* **Spam or wrong copy** — Message text is whatever the client passes; trim at source if user-facing strings are too technical.
* **Double `GameManager`** — **`Initialize`** warns if already initialized; ensure a single subsystem instance on the prefab.

## Related

* [HttpClient](/core/http-client)
* [Modal manager](/core/modal-manager)
* [RuntimeManager](/core/runtime-manager)
* [Localization](/core/localization)

## Unity Editor

<Frame caption="GameManager Inspector">
  <img src="https://mintcdn.com/ptmolcateknologinusantara/qXrgFMk4QevJTANv/images/features/shared/game-manager-inspector.png?fit=max&auto=format&n=qXrgFMk4QevJTANv&q=85&s=9820894627fb922b0ab24e45437cdbb8" alt="Game Manager Inspector" width="592" height="192" data-path="images/features/shared/game-manager-inspector.png" />
</Frame>
