# Login Scene

### 1. Scene Hierarchy (Key Objects)

<figure><img src="/files/fg85Raz8M64KF7a5Iwsi" alt=""><figcaption></figcaption></figure>

```
Login
 ├─ Main Camera
 ├─ Directional Light
 ├─ EventSystem
 ├─ Canvas
 │   └─ AuthManagerUI (includes login & register forms)
 ├─ Game Managers
 │   ├─ GameInstance
 │   ├─ LanguageManager
 │   ├─ AudioManager
 │   └─ MapRewardManager
 ├─ Backend Settings
 │   ├─ BackendBootstrap
 │   ├─ BackendManager
 │   └─ ExportDataJson (WebSocket only)
 ├─ Networking
 │   └─ PhotonFusionNetworkManager
 ├─ Loading Manager
 │   └─ LoadingManager
 └─ Local Scene Audio
     └─ LoginAmbientAudio
```

### 2. Component Reference

| GameObject / Component         | Purpose                                                                                                                                                            |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **AuthManager** (on *Canvas*)  | Orchestrates login / registration UI and forwards credentials to **BackendManager**.                                                                               |
| **LanguageManager**            | Stores all text translations and switches fonts or uppercase rules at runtime.                                                                                     |
| **AudioManager**               | Central audio hub: groups by tag, enforces max voices, exposes volume sliders.                                                                                     |
| **MapRewardManager**           | Grants one‑time rewards when a map is cleared for the first time.                                                                                                  |
| **GameInstance**               | *Singleton*. Holds every static dataset: characters, icons, frames, maps, currencies, balance caps, etc. Used by nearly all other systems.                         |
| **BackendBootstrap**           | Injects the selected backend implementation (Offline, Firebase, WebSocket) at scene start.                                                                         |
| **BackendManager**             | Handles sign‑in flow, data load / save, remote validation and daily quest timers.                                                                                  |
| **ExportDataJson**             | Editor‑only helper that exports local JSON files needed by the WebSocket + SQL backend. Click *Export All Game Data* while the game is running in the Login scene. |
| **PhotonFusionNetworkManager** | Hosts / joins lobbies for Co‑op and PvP modes using Fusion 2.                                                                                                      |
| **LoadingManager**             | Displays the animated loading screen, enforces a minimum display time and plays scene‑transition SFX.                                                              |
| **LoginAmbientAudio**          | Looping ambience dedicated to the Login scene, routed through **AudioManager**.                                                                                    |

***

### 3. Typical Flow

1. **BackendBootstrap** reads `BackendSettings.asset` and instantiates the correct backend service.
2. **AuthManager** shows the login UI. Creating an account (guest or email/password) triggers **BackendManager** to fetch or create player data.
3. **GameInstance** caches the data for global access.
4. On successful login, **LoadingManager** transitions to the Home scene.

***

### 4. Tips & Best Practices

* **Do not delete `GameInstance`**. Many scripts assume it exists in every gameplay scene.
* When using the **WebSocket backend**, always export fresh JSON with **ExportDataJson** after you edit any GameData.
* Keep **LanguageManager** near the top of the execution order if you plan to swap languages early.
* For custom SFX, add new tags in **AudioManager** rather than hard‑coding audio sources.

***

### 5. Extending the Scene

* Add new managers inside the **Game Managers** group to keep the hierarchy tidy.
* If you replace the login system, keep its public events (`OnLoginSuccess`, `OnLoginFailed`) so other components remain compatible.
* For additional ambient tracks, duplicate **LoginAmbientAudio** and assign a unique AudioMixer group.

***

> **Need help?** Join the community: <https://discord.com/invite/EGGj77g3eQ>


---

# Agent Instructions: 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:

```
GET https://bizachi-dev.gitbook.io/bullethell-elemental-template/user-interface-menus/editor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
