Applies to: Molca VR SDKDocumentation 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.
Overview
This recipe shows you how to create a complete VR training scenario from scratch. You’ll create a Scenario Data Config asset, set up a scenario scene with ScenarioManager, add activities with VR-specific steps, and configure the session flow. This is the foundation for building immersive VR training experiences with ordered tasks, scoring, and backend integration.Prerequisites
- SDK modules: Molca Core, Molca VR SDK installed
- Unity setup: RuntimeManager configured, XR Plugin Management installed, GlobalSettings configured
- Prior knowledge: RuntimeManager, SequenceController, Step
Step-by-step
Step 1: Create a Scenario Data Config asset
Create aScenarioDataConfig asset to register your scenario collections and configure execution mode.
ScenarioDataConfig is a SettingModule that tells the runtime which scenarios exist and how to resolve them by ID. It’s loaded during RuntimeManager initialization and used by the session system to find scenario assets.
Step 2: Create a Simulation Scenario Data asset
Create aSimulationScenarioData asset that defines your training scenario metadata.
SimulationScenarioData holds the metadata that links your scenario asset to its Unity scenes via the SceneLoadPlan structure. The RefId is used for local lookups, while ScenarioId (org ID, set later) links to backend scenarios. The SceneLoadPlan supports ordered multi-scene loading — preload scenes load first (environment, shared assets), then the main scenario scene.
Step 3: Add the scenario to ScenarioDataConfig
Add your scenario data asset to theScenarioDataConfig collections.
ScenarioDataConfig uses collections to register available scenarios. At runtime, methods like GetScenarioDataByScenarioId search these collections to resolve scenario references.
Step 4: Create the scenario Unity scene
Create a new Unity scene for your VR scenario and add the VR Scenario prefab.[VR Scenario] prefab provides the complete VR runtime infrastructure: XR Origin for tracking, ScenarioManager for orchestration, scenario UI for pause/completion, and player management. This ensures consistent VR setup across all scenarios.
Step 5: Configure ScenarioManager
Select theScenarioManager component in your scene and configure it to reference your scenario data.
ScenarioManager is the runtime orchestration component that manages scenario state (Inactive, Active, Completed), drives activities in order, and integrates with the session system. The scenarioData reference links the scene to your scenario metadata.
Step 6: Create activity GameObjects
Under theScenarioManager, create child GameObjects for each training activity.
ScenarioActivity wraps a SequenceController and integrates with scoring and session posting. The activityId field links the runtime component to backend activity metadata when using connected sessions.
Step 7: Add VR steps to activities
Create child GameObjects under each activity and add VR step components.Step subclasses that handle VR interactions. LookAtStep completes when the user gazes at a target for a duration. GrabStep completes when the user grabs a specific object. The SequenceController executes these steps in hierarchy order.
Step 8: Wire activities to ScenarioManager
Add your activity GameObjects to theScenarioManager.activities array.
ScenarioManager executes activities in array order (unless startAllActivitiesSimultaneously is checked). When an activity’s sequence completes, the manager advances to the next activity or completes the scenario.
Step 9: Configure session flow (optional)
For production scenarios with backend integration, configure the session flow.ScenarioSessionManager handles backend session creation, scene loading via Addressables, and progress tracking. The CreateSessionAsync call establishes a session with the backend, and LoadSessionWithProgressAsync loads the scenario scene and starts the training. This flow requires useSessionManager to be checked on ScenarioManager.
Complete example
Here’s a complete custom VR step that waits for the user to press a button before completing:ScenarioActivity, and it will wait for the user to interact with the specified button before advancing.
Troubleshooting
- Scenario never starts: Ensure
RuntimeManager.WaitForInitialization()completes before callingStartScenario(). If usingautoStart, verify theScenarioManageris active in the scene. - Activities don’t advance: Check that each activity’s
SequenceControlleris properly configured and that steps callComplete()when finished. Use the Sequence Visualizer to debug step hierarchy. - Session creation fails: Verify
ScenarioNetworkConfigendpoints are correct, authentication token is valid, andorgScenarioIdexists in the backend. CheckOnErrorevent logs. - Scene doesn’t load: Confirm the
SceneLoadPlanis configured inSimulationScenarioData— check thatsinglePlayerPlan.scenarioScenehas eithersceneNameorsceneReferenceset. For Addressables, verify the scene is marked as Addressable and the key matches exactly. - Steps execute out of order: Steps execute in hierarchy order (top to bottom). Reorder GameObjects in the Hierarchy or check for parallel step configurations.
- Preload scenes don’t load: Verify
singlePlayerPlan.preloadScenesarray is populated. Index 0 loads as Single (active scene); subsequent entries load Additive. Check console for scene load errors. - Scene loads but objects missing: Check
waitForRefIdson preload scene entries — the executor waits up to 15 seconds for those RefIds to be registered inReferenceManager. If timeout occurs, check console warnings.
Related
- Scenario Data — ScriptableObject asset that defines scenario metadata and scene loading
- Scenario Data Config — scenario collections and execution mode configuration
- VR session flow — session creation, loading, and event handling
- ScenarioManager — scenario state machine and activity orchestration
- Recipe: Set up a basic sequence — foundational sequence and step concepts
- VR content hierarchy — understanding the module → scenario → activity → step structure
- Look At Step — VR step for gaze-based interactions
- Grab Step — VR step for object grabbing interactions