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

# Scenario UI

> Completion screens, leaderboard rows, and in-scenario HUD.

**Folder:** `Assets/_MolcaSDK/_VR/Scripts/Scenario/UI/`\
**Namespace:** `MolcaSDK.VR.Scenario.UI`

Primary documented completion surface: **`ScenarioCompletionUI`** — listens to **[ScenarioManager](/vr/scenario-manager)** completion / timeout / fail events, shows header + mascot, local player stats, and fetches leaderboard rows via **[ScenarioSessionManager](/vr/session-authentication)**.

Other HUD or modal helpers may live in the same folder or under `Modals`; search **`Scenario/UI`** in the SDK.

## Step task list (titles from `StepInfo`)

The in-scenario **task** or **checklist** UI (names vary by prefab) lists training steps for the current activity. Each row’s **title** (and sometimes description) usually comes from the **`StepInfo`** **`StepAuxiliary`** on that step:

* Active / completed styling is driven by [Step](/core/step) status from the [SequenceController](/core/sequence-controller).
* Copy is driven by **`StepInfo`** on each step — use **localization** on the same fields modals use so the list matches [Popup step](/vr/steps/popup-step) and other UIs.
* **Subclasses** of **`StepInfo`** can add fields for custom HUD or CSV-imported data ([CSV Step Importer](/core/csv-step-importer)); the standard list typically displays the **base title** from the auxiliary.

See [VR step auxiliaries](/vr/steps/vr-step-auxiliaries) for adding **`StepInfo`** and derived types.

## When to use

Use **`ScenarioCompletionUI`** when a scenario scene needs an **end screen**: success vs timeout vs failure copy, **score and duration** from **`ScenarioManager`**, and a **leaderboard** for the current org scenario.

## Inspector setup (`ScenarioCompletionUI`)

| Section                  | Fields                                                                            |
| ------------------------ | --------------------------------------------------------------------------------- |
| **References**           | **`ScenarioManager`** — must be set or **OnEnable** subscriptions never fire.     |
| **Panels**               | **Completion panel**, header **TMP** / **Image**, **mascot** image.               |
| **Completion indicator** | **Success / failed** colors; success/fail **sprites**.                            |
| **Player stats**         | Name, score %, duration, **change scenario** / **play again** buttons.            |
| **Leaderboard**          | **Container** transform, **entry prefab**, row colors, rank 1–3 icons.            |
| **Events**               | **`onChangeScenario`**, **`onPlayAgain`** — wire to session navigation or reload. |

On **Awake**, **completion panel** starts inactive. **OnEnable** registers **`OnScenarioComplete`**, **`OnScenarioTimeout`**, **`OnScenarioFail`** on **`ScenarioManager`**.

## Code

**Dispatch UnityEvents from the Inspector** — no code required for basic flow. To trigger navigation in script, listen on your bootstrap:

```csharp theme={null}
using MolcaSDK.VR.Scenario.UI;
using UnityEngine;

public class CompletionFlow : MonoBehaviour
{
    [SerializeField] private ScenarioCompletionUI ui;

    private void OnEnable()
    {
        ui.onChangeScenario.AddListener(GoHome);
        ui.onPlayAgain.AddListener(ReloadScenario);
    }

    private void OnDisable()
    {
        ui.onChangeScenario.RemoveListener(GoHome);
        ui.onPlayAgain.RemoveListener(ReloadScenario);
    }

    private void GoHome() { /* load home / request session */ }
    private void ReloadScenario() { /* reload current scenario scene */ }
}
```

`Show` resolves **`ScenarioSessionManager`** via **`RuntimeManager.GetSubsystem`** for leaderboard API calls.

## Troubleshooting

* **Nothing appears on completion** — **`scenarioManager`** reference is null (error logged) or **`ScenarioManager`** never raises completion events.
* **Leaderboard empty / warning** — Session not ready, missing **bearer** context, or **`scenarioData.OrgScenarioId`** invalid; check network logs and [Scenario network config](/vr/scenario-network-config).
* **Wrong player name** — Pulled from **`SessionInfo.user.name`**; verify session payload after login.
* **Double subscriptions** — Avoid enabling/disabling the component repeatedly without matching **OnDisable**; use a single active instance.

## Related

* [VR step auxiliaries](/vr/steps/vr-step-auxiliaries) — **`StepInfo`** for task-list titles
* [ScenarioManager](/vr/scenario-manager) — completion events and scores
* [Session authentication](/vr/session-authentication) — **`ScenarioSessionManager`**, session info
* [Scenario network config](/vr/scenario-network-config) — leaderboard HTTP
* [Home UI](/vr/home-ui) — typical **change scenario** target

## Unity Editor

<Frame hint="Scenario completion canvas in Scene view or ScenarioCompletionUI Inspector." caption="Scenario completion / leaderboard UI">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/ptmolcateknologinusantara/images/features/vr/scenario-ui-completion.png" alt="Scenario completion UI in Unity" />
</Frame>
