Options for the mode of a IVariableNode, which determines the ports it exposes.
The mode controls how the node interacts with the variable's value and which ports are available on it.
A VariableNodeMode.Get node is the default mode for all variable kinds. For variables of kind
VariableKind.Local or VariableKind.Input, it exposes an output port.
For variables of kind VariableKind.Output, it exposes an input port.
A VariableNodeMode.Set node exposes an extra input port, so that you can assign the value directly in the graph.
Only variables of kind VariableKind.Local support VariableNodeMode.Set mode.
Variables of kind VariableKind.Input or VariableKind.Output always use VariableNodeMode.Get mode.
To change the mode of an existing variable node, use the Allow to set value in graph checkbox in the node's inspector.
// Create a local variable and add both a get node and a set node to the graph. IVariable speed = graph.CreateVariable<float>("Speed");
graph.UndoBeginRecordGraph("Add Variable Nodes"); IVariableNode getNode = graph.AddVariableNode(speed, new Vector2(100, 100)); IVariableNode setNode = graph.AddVariableNode(speed, new Vector2(100, 200), VariableNodeMode.Set); graph.UndoEndRecordGraph();
// getNode.Mode == VariableNodeMode.Get // Speed is a local variable, so getNode has an output port that provides its current value.
// setNode.Mode == VariableNodeMode.Set // setNode has an extra input port for writing the value of Speed in the graph.