Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

VariableNodeMode

enumeration

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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.

Properties

Property Description
Get Determines the node's ports from the variable's kind. This is the default mode.@@@@`
Set Exposes an extra input port for writing a new value to the variable directly in the graph.