Variables

Variable declarations, Get/Set nodes, reference bindings, and drag-to-canvas interactions.

When variablesEnabled = true in the GraphSystemDescriptor, the framework provides a complete variable system for storing and reading named values within a graph.

 

Variable Panel

The Variable Panel is a dock widget with a table listing all declared variables. Each variable has:

  • Name — User-defined identifier
  • Data Type — Selected from a dropdown of registered types (Bool, Int, Float, String, etc.)
  • Default Value — Type-specific editor (checkbox for Bool, spinner for numeric, text field for String, multi-field for vectors, color picker for Color)

Variables are per-graph. Add or remove variables using the panel controls. Undo/redo integration is automatic.


Get / Set Variable Nodes

When variables are enabled, GetVariableNode and SetVariableNode are automatically included in the node palette under the “Variables” category.

  • GetVariableNode — Outputs the current value of a named variable
  • SetVariableNode — Writes a value to a named variable

Both nodes reference a variable by name. If the variable is renamed, all referencing Get/Set nodes update automatically.


Convert to Reference

Right-click any typed input slot on a node to convert it to a variable reference. A dropdown appears listing all declared variables that match the slot’s data type. Once bound:

  • The slot displays the variable name instead of an inline value
  • The slot reads the variable’s value at evaluation time
  • Right-click again and select “Convert to Value” to unbind

Reference bindings are persisted as VariableBinding structs (NodeId + SlotName + VariableId) and restored automatically on load.


Drag to Canvas

Drag a variable from the Variable Panel directly onto the graph canvas. A popup menu asks whether to create a Get or Set node for that variable. The node is automatically configured with the variable name and data type.


Runtime Variable Access

At runtime, variables live in the GraphExecutionContext blackboard. The execution context provides:

  • Read/write access by variable name
  • InitializeBindings() resolves VariableId references to names
  • Variable changes can trigger re-evaluation (in DataFlowGraph, MarkDirty(variableName) propagates to dependent nodes)

Downstream gems expose variable control through their own APIs. For example, the Audio Event Graph provides SetAudioGraphVariable(instanceId, name, value) to control graph variables from gameplay code.