Skip to main content

Scene Graph Quick Start

This guide walks through creating a Scene Graph for a study with four trial orders, where participants are automatically assigned to one based on their Subject ID. By the end, you will have a complete graph assigned as the Active Scene Graph, ready to run when you press Play in the Unity Editor.

The diagram below shows the complete flow of the study, moving from start to finish left to right:

Experiment flow diagram

The study begins with a Pre-study consisting of three scenes every participant completes: Consent and Instructions, Pre-experiment Survey, and Practice. This is followed by the Main Study, made up of four trials. Each trial contains a driving task, a survey, and a report. Participants experience the four trials in different orders determined by their Subject ID. After the Main Study, all participants converge on a Post-survey to conclude the session.

Prerequisites​

Before starting this guide:

  • Confirm all required scene maps are created and marked as Addressable.
  • Confirm the Bootloader is enabled so the graph runs from the beginning when you press Play.

1. Create the Scene Graph Asset​

1
Navigate to the Graph folder

In the Project window, navigate to Assets/mobisim/Scenes/Graph.

Folder location

2
Open the context menu

Right-click in the Project window to open the context menu.

3
Select the asset type

Select Create > ScriptableObject > Scene Network Graph.

Context menu

4
Rename the asset

Rename the asset to reflect the study it represents.

Named Scene Graph asset

2. Add the Start Node​

Every Scene Graph requires a Start node. Without one, the simulator cannot begin the experiment.

1
Open the asset in the Scene Graph Editor

Double-click the Scene Graph asset in the Project window to open it in the Scene Graph Editor.

2
Confirm the correct asset is open

The Scene Graph Editor (window title SceneGraph) opens with an empty graph. Confirm the correct asset is open by checking the read-only object field in the toolbar at the upper left. Changes to the graph are saved automatically (controlled by the xNode Autosave preference, enabled by default).

Scene Graph Editor window

tip

Click the object field to locate the asset in the Project window.

3
Open the node context menu

Right-click in an empty area of the graph to open the node context menu.

Node context menu

tip

Right-click and drag to pan around the graph.

4
Select Start from Flow Control

Expand Flow Control in the context menu and select Start.

note

If Start is grayed out, a Start node already exists in the graph.

Start node option in context menu

The graph now has a Start node. The following steps connect nodes to its output pin to define the study flow.

Start node

3. Build the Pre-study​

The Start node marks the entry point but does not execute anything on its own. Without a connected node, the simulator finds the Start node, detects nothing to execute, and ends the session immediately. Connect the Start node to a Scene node to load the first scene map.

1
Drag a wire from the Start node

Click the output pin of the Start node, drag the wire into an empty area of the graph, and release it to open the context menu.

Context menu opened from wire

2
Add a Scene node

Select Scene from the context menu.

Scene option highlighted

The Scene node is added and connected to the Start node.

Start node connected to Scene node

3
Open the asset picker

Click the small circle on the right side of the object field in the Scene node to open the asset picker.

Object field circle highlighted

4
Assign the Consent and Instructions scene map

Select the Consent and Instructions (TODO:-Insert-Scene-Name) scene map.

note

If the scene map does not appear in the picker, it may not be marked as Addressable. Follow these steps to mark a scene map as Addressable.

Scene node with assigned map

5
Add the remaining Pre-study Scene nodes

Create two additional Scene nodes and assign the Pre-experiment Survey (TODO:-Insert-Scene-Name) and Practice (TODO:-Insert-Scene-Name) scene maps respectively.

Two additional Scene nodes

6
Connect the three Scene nodes in sequence

Connect the three Scene nodes in sequence:

  • Consent output → Pre-experiment Survey input
  • Pre-experiment Survey output → Practice input

Three Scene nodes connected in sequence

The Pre-study is now configured. The following section sets up the Main Study with branching logic.

4. Construct the Main Study​

The Pre-study uses a linear structure — every participant follows the same path. The Main Study assigns each participant to one of four trial orders based on their Subject ID.

The assignment uses a modulo operation: divide the Subject ID by 4 and use the remainder to select the trial order.

Subject IDCalculationResultTrial Order
88 % 40First
55 % 41Second
1010 % 42Third
77 % 43Fourth
note

Counting starts from 0. A result of 0 corresponds to the first trial order, 1 to the second, and so on.

This logic is implemented using an Int Variable node, a Modulo operator node, and a Switch node.

1
Add a Switch node after the Practice scene

Drag from the output pin of the Practice Scene (TODO:-Insert-Scene-Name) node and select Flow Control > Switch from the context menu.

Switch option in context menu

2
Add and label four output pins

In the Switch node, click + four times to add four output pins. Label them 0, 1, 2, and 3 respectively.

Switch node with four labeled outputs

3
Add an Int Variable node

Right-click in an empty area of the graph and select Reference > Int Variable.

4
Set the Int Variable node to Use Variable

Click the three-dot menu on the left side of the Int Variable node and select Use Variable from the dropdown.

Reference Variable dropdown

The input field changes to an object field.

5
Select SubjectIDVariable

Click the circle icon inside the object field to open the asset picker and select SubjectIDVariable.

Asset picker with SubjectIDVariable

6
Add a Modulo node

Right-click in an empty area and select Operator > % to add a Modulo node.

Modulo option in context menu

7
Enter the divisor

Enter 4 into the bottom input pin of the Modulo node.

Modulo node with 4 entered

8
Add two Cast nodes to resolve pin type mismatches

The Int Variable node output cannot connect directly to the Modulo node due to a pin type mismatch. Add two Cast nodes from the context menu to resolve this — one between Int Variable and Modulo, and one between Modulo and Switch.

Two Cast nodes positioned between the three nodes

9
Connect the first Cast node

Connect the Int Variable output to the first Cast node's input. Set its output type to float, then connect the output to the upper input pin of the Modulo node.

First Cast node connected

10
Connect the second Cast node

Connect the Modulo output to the second Cast node's input. Set its output type to string, then connect the output to the Switch node's Selection input.

Second Cast node connected

11
Build the first trial order

Create the first trial order by adding three Scene nodes and assigning the driving task, survey, and report (TODO:-Insert-Scene-Name) scenes respectively. Connect them in sequence.

First trial order

12
Repeat for the remaining three trial orders

Repeat step 11 for the remaining three trial orders, rearranging the scene order in each to produce four unique sequences. You will have twelve Scene nodes in total.

tip

Copy and paste the first trial order, then reorder the scenes in each copy rather than building each order from scratch.

Four trial order routes

13
Connect the Switch outputs to each trial order

Connect each output pin of the Switch node (0, 1, 2, 3) to the input pin of the first Scene node in its corresponding trial order.

note

Pin 0 routes participants whose Subject ID modulo 4 equals 0, pin 1 routes those where the result equals 1, and so on.

Switch node connected to four trial orders

The Main Study portion of the graph is now complete. After the Practice scene, the simulator branches into one of the four trial orders based on the participant's Subject ID.

Completed Main Study

Configuring the Default Pin​

The Switch node includes a Default output pin that activates when no labeled pin matches the incoming value. In this study, the modulo result is always between 0 and 3, so the Default pin should not activate under normal conditions. However, if the result is negative, non-integer, or NaN due to an error, the Default pin fires; if it is not connected, the graph ends and the participant is unable to proceed.

Switch node Default pin highlighted

Connect the Default pin using one of the following approaches:

  • Route to an existing trial order — the experiment continues despite the invalid output.

    Default connected to trial order

  • Route to an error scene — a dedicated scene informs the participant of the issue.

    Default connected to error route

5. Converge to the Post-survey​

All participants complete the post-survey, regardless of trial order. The four trial paths merge into a single flow for this final section.

1
Add the Post Survey Scene node

Create a Scene node and assign the Post Survey (TODO:-Insert-Scene-Name) scene map.

Post Survey Scene node

2
Connect all four trial orders to the Post Survey

Connect the output pin of the last Scene node in each of the four trial orders to the input pin of the Post Survey Scene node.

Post Survey Scene node connected to four routes

3
Add a Thank You closing scene

Drag from the output pin of the Post Survey Scene node and create another Scene node. Assign the Thank You For Playing (TODO:-Insert-Scene-Name) scene.

note

Data is saved and transferred immediately before each scene transition. Without a subsequent scene after the post-survey, data may not be saved. A closing scene also signals to participants that the study is complete.

Thank You scene node

4
Add an End node

Drag from the output pin of the Thank You Scene node and select Flow Control > End from the context menu.

note

The simulator adds an End node automatically at runtime when it reaches the end of a flow. Adding one manually improves graph readability.

End node

The graph is now complete.

6. Review and Test​

To improve readability, add Comment boxes to label sections of the graph. Right-click anywhere in the graph, select Comment, then resize and reposition the box as needed. See Comment Boxes for more details.

Completed graph with Comment boxes

Press Play in the Unity Editor to test the full graph and verify the flow runs as expected.

tip

To test a specific trial order without the modulo logic, disconnect the second Cast node from the Switch node's Selection input. A text input field labeled Selection appears on the Switch node. Enter the branch number to test — for example, entering 1 runs the trial order connected to branch 1.

To test a different branch, change the Selection value manually. This method does not cycle through branches automatically.