Skip to main content
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
  • 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: 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; PlayerId from SessionInfo.

Code

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.

Unity Editor

RuntimeManager prefab → ScenarioSessionManager Inspector (network assets + read-only session fields in Play Mode).

ScenarioSessionManager RuntimeSubsystem Inspector