Unity technical documentation Version 1.1.0

Training Blackboard

Typed scene variables for VR training flows. Use it on its own, with UnityEvents and no-code bindings. Netcode for GameObjects, XR Interaction Toolkit, and VR Builder are optional modules that turn on when those packages are installed.

com.themetrics.training-blackboard · Unity 6 (6000.0) or newer

Quick start

  1. Create the blackboard

    Create an empty GameObject and add Training Blackboard (Add Component → Training Blackboard → Training Blackboard).

  2. Declare variables

    For example score (Int), doorOpen (Bool), or elapsed (Float).

  3. Write a value

    Add BlackboardVariableSetter to a button or interactable and call Apply from its event.

  4. React

    Add BlackboardVariableListener, for example score >= 10, and hook your logic to the success event.

  5. Show it

    Add BlackboardTextBinding next to a TextMesh Pro and use the template Score: {score}.

Variables

Each variable has a name, a type (Bool, Int, Float, or String), a default value, and an optional Sync flag. Details in the inspector opens the rest of the settings.

  • Description is a tooltip for designers. It also appears in the Live Debugger.
  • Clamp to range keeps Int and Float values between Min and Max. Every write is clamped, including operations and network writes.
  • Named options turn an Int into an enum, for example 0: Idle, 1: Running, 2: Done. Inspectors and VR Builder drawers show a popup, and text bindings show the label.

In Play Mode the inspector shows the live value next to the default, and adds Reset All and Copy JSON.

Rename renames a variable and updates the setters, listeners, bindings, and timers in the open scenes that read it. You can also update the VR Builder process files in Assets/StreamingAssets/Processes. Rename matches by variable name. Close the Process Editor before renaming and reopen it afterwards.

Text templates use {name} for the value. An Int with options shows the label. {name:0.00} uses a .NET format string. {name:#} shows the raw number of an options variable. {name:Open|Closed} picks the label for a Bool, true first. Escape literal braces with {{ and }}. Numbers use the invariant culture unless you enable Use Device Culture.

Operations and comparisons

Setters, the VR Builder Change Variable behavior, and TrainingBlackboard.ApplyOperation share these operations.

Operations by type
Type Operations
Bool Set, Toggle, Random (coin flip), Reset.
Int / Float Set, Add, Subtract, Multiply, Divide, Min, Max, Random Range, Reset.
String Set, Append, Reset.
  • The operand can be a literal or another variable, read when the operation runs. Int and Float can be mixed.
  • Random Range on an Int includes both ends.
  • Int arithmetic saturates instead of overflowing. Division by zero is ignored and logs a warning.

Listeners and the VR Builder conditions support ==, !=, <, <=, >, and >= on numbers, plus Contains, Starts With, and Ends With on strings. You can compare against a literal or against another variable, on the same blackboard or a different one.

Multi-variable comparisons use the usual precedence: AND binds tighter than OR. a AND b OR c means (a AND b) OR c.

Components

Training Blackboard components
Component Role
TrainingBlackboard Stores the variables. Exposes ValueChanged, operations, snapshots, and reset.
BlackboardVariableSetter Writes from a UnityEvent: Apply, ApplyWithFloat/Int/String/Bool, ResetVariable.
BlackboardVariableListener Fires a UnityEvent when a comparison becomes true, on every rising edge or only once.
BlackboardMultiVariableListener An AND/OR chain of comparisons.
BlackboardTimer Counts a Float or Int up or down. A Bool “running” variable starts and pauses it.
BlackboardTextBinding Fills a template such as Time: {elapsed:0.0}s into TextMesh Pro, UI Text, or a UnityEvent<string>.
BlackboardVariableBinding Forwards a variable as typed events: bool, int, float, string, normalized 0 to 1, or true/false.
BlackboardAnimatorBinding Drives Animator parameters from variables. A Trigger fires when its Bool becomes true.
BlackboardSessionRecorder Records every change and saves a JSON report to Application.persistentDataPath.
NetworkedBlackboard NGO replication for Sync variables. Optional module.
BlackboardInteractableBinding Writes hovered, selected, activated, and select count from an XRI interactable. Optional module.
BlackboardSocketBinding Writes has-item, item name, and correct-item from an XRI socket. Optional module.
TrainingBlackboardProperty Bridge to VR Builder scene properties. Optional module.

Give the timer a Bool Running variable. A VR Builder Change Variable that sets it to true starts the timer, and false pauses it. Compare the value, for example elapsed >= 30 or remaining <= 0 when counting down, to branch the process. In multiplayer only the authority advances the timer, and its writes are throttled by Network Write Interval.

CaptureSnapshot() returns a BlackboardSnapshot that can be serialized with ToJson(). RestoreSnapshot() writes the values back through the normal path, so they replicate. Use snapshots for save points, analytics, or checking results.

Netcode, XRI, and VR Builder

Networking compiles only when Netcode for GameObjects 2.x is installed. Without the companion component, everything stays local.

  1. Add Networked Blackboard (NGO) to the same GameObject. It also needs a NetworkObject.
  2. Enable Sync on the variables you want replicated.
  • The object owner applies every write. Other peers send the write to the owner as an RPC.
  • Operations such as Add and Multiply are sent as operations rather than final values, so simultaneous writes from several players compose correctly.
  • Sync slots are matched by a stable name hash, not by inspector list order.
  • Up to 64 synced variables per blackboard. Synced strings are limited to 509 bytes of UTF-8. Longer strings are cut at a character boundary, with one warning per variable.
  • Replication starts after the owner seeds the networked entries.

When XR Interaction Toolkit 3.x is installed, the TrainingBlackboard.XRI assembly adds the interactable and socket bindings. They look up the blackboard on the same GameObject or its parents when none is assigned.

When co.mindport.vrbuilder.core and Newtonsoft JSON are installed, the VR Builder assembly compiles automatically. Add Training Blackboard Property (VR Builder) to the blackboard GameObject. In the Process Editor you get:

VR Builder pieces
Menu Type What it does
Variables/Change Variable Behavior Applies any operation. The operand can be a literal or another variable.
Variables/Reset Variables Behavior Resets one variable or the whole blackboard to its defaults.
Variables/Compare Variable Condition Compares against a literal or another variable.
Variables/Compare Multiple Variables Condition An AND/OR chain, with an optional hold duration.
Variables/Variable Changed Condition Completes after a variable changes N times.

When a step is skipped (fast-forward), comparison conditions write the expected value by default, so later steps see a consistent state. Turn off Apply On Fast Forward to keep the current value.

Samples/PumpLotoDemo contains a lockout/tagout scene builder that uses the blackboard together with VR Builder, Directional Indicator, and Display Step Canvas.

Debugger and assemblies

Tools → TheMetrics → Training Blackboard → Live Debugger lists every blackboard in the open scenes. In Play Mode you can edit values (the writes replicate), see how long each value has been held, and read the change history.

[BlackboardVariable] is an attribute for your own scripts. It draws a string field as a popup of the blackboard variables, filtered by type.

When each assembly compiles
Assembly When
TrainingBlackboard.Runtime Always.
TrainingBlackboard.Editor In the editor.
TrainingBlackboard.NGO With Netcode for GameObjects 2.x.
TrainingBlackboard.XRI With XR Interaction Toolkit 3.x.
TrainingBlackboard.VRBuilder With VR Builder and Newtonsoft JSON.
TrainingBlackboard.VRBuilder.Editor In the editor, with VR Builder.

Common problems

A condition does not see the variable name

The name has to match exactly. Use Rename to update setters and listeners, and reopen the VR Builder Process Editor after renaming.

The value does not reach other players

Add NetworkedBlackboard and a NetworkObject, and enable Sync on that variable. There is a cap of 64 synced variables.

The VR Builder menu does not appear

co.mindport.vrbuilder.core and Newtonsoft JSON are required. Then add Training Blackboard Property (VR Builder) to the GameObject.

A skipped step leaves the old value

By default a comparison writes the expected value on fast-forward. Turn off Apply On Fast Forward if that is not what you want.

Back to Unity development