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

# Session loading and events

> CreateSession, LoadSession helpers, scene load, and UnityEvents on ScenarioSessionManager.

**File:** `Assets/_MolcaSDK/_VR/Scripts/Scenario/Session/ScenarioSessionManager.cs`

## When to use

Use `ScenarioSessionManager` for backend-bound VR runs where you must create/auth a session, load scenario content, and report progress/score/status through server APIs.

## Representative APIs

Confirm signatures in source; typical flows include:

* **`CreateSessionAsync(int orgScenarioId, string mode = "TRAINING")`**
* Start / status / score methods bound to [Scenario network config](/vr/scenario-network-config)
* **`LoadSessionWithModalAsync`** — modal + session create + start + scenario scene load
* **`LoadSessionWithProgressAsync`** — same with **`OnLoadingProgress`** (0–1 + status string)

## Load session with modal (conceptual)

Exact steps follow `ScenarioSessionManager` source; typical ordering:

```mermaid theme={null}
flowchart TD
  A[LoadSessionWithModalAsync] --> B[Show loading UI]
  B --> C[CreateSessionAsync]
  C --> D[StartScenarioAsync]
  D --> E[Load scenario scene with progress]
  E --> F[Fade / addressables as configured]
  F --> G[Hide loading UI]
  G --> H[Scenario scene running]
```

Use **`LoadSessionWithProgressAsync`** when you supply your own progress UI instead of the default modal.

## UnityEvents

`OnTokenReceived`, `OnContentLoaded`, `OnScenarioStarted`, `OnScorePosted`, `OnSessionStatusChanged`, `OnError`, `OnScenarioSceneLoaded`, `OnScenarioSceneUnloaded`, `OnLoadingProgress`.

## Identifiers

**`OrgId`** may come from [DeviceManager](/vr/device-manager); **`PlayerId`** from `SessionInfo`.

## Code

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

public class TrainingBoot : MonoBehaviour
{
    private async void Start()
    {
        await RuntimeManager.WaitForInitialization();
        var session = RuntimeManager.GetSubsystem<ScenarioSessionManager>();
        if (session == null) return;

        var created = await session.CreateSessionAsync(orgScenarioId: 42, mode: "TRAINING");
        if (!created) return;
        // Then LoadSessionWithModalAsync / LoadSessionWithProgressAsync per your UX
    }
}
```

Confirm parameter names and overloads in **`ScenarioSessionManager.cs`** for your SDK revision.

## Troubleshooting

* **`CreateSessionAsync` returns false:** verify auth/token stage, org scenario id, and network configuration assets.
* **Loading stalls before scene start:** inspect `OnLoadingProgress` and `OnError`; validate Addressables/scene keys used by scenario content.
* **Events not firing in listeners:** subscribe after `RuntimeManager.WaitForInitialization()` and unregister on disable.

## Related

* [Scenario network config](/vr/scenario-network-config)
* [Scenario Data Config](/setup/scenario-data-config)
* [Scenario manager](/vr/scenario-manager)

## Unity Editor

<Frame hint="RuntimeManager prefab → ScenarioSessionManager Inspector (network assets + read-only session fields in Play Mode)." caption="ScenarioSessionManager on RuntimeManager prefab">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/ptmolcateknologinusantara/images/features/vr/scenario-session-manager-inspector.png" alt="ScenarioSessionManager RuntimeSubsystem Inspector" />
</Frame>
