# VariableNodeMode

> Options for the mode of a IVariableNode, which determines the ports it exposes.

## Definition

* **Type:** Enum
* **Namespace:** [Unity.GraphToolkit.Editor](/engine/6000.7/script-reference/unity/graphtoolkit/editor.md)
* **Assembly:** UnityEditor

```csharp
public enum VariableNodeMode
```

## Remarks

The mode controls how the node interacts with the variable's value and which ports are available on it.

A [VariableNodeMode.Get](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablenodemode/get.md) node is the default mode for all variable kinds. For variables of kind [VariableKind.Local](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablekind/local.md) or [VariableKind.Input](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablekind/input.md), it exposes an output port. For variables of kind [VariableKind.Output](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablekind/output.md), it exposes an input port.

A [VariableNodeMode.Set](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablenodemode/set.md) node exposes an extra input port, so that you can assign the value directly in the graph. Only variables of kind [VariableKind.Local](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablekind/local.md) support [VariableNodeMode.Set](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablenodemode/set.md) mode. Variables of kind [VariableKind.Input](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablekind/input.md) or [VariableKind.Output](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablekind/output.md) always use [VariableNodeMode.Get](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablenodemode/get.md) mode.

To change the mode of an existing variable node, use the **Allow to set value in graph** checkbox in the node's inspector.

## Examples

```csharp
// 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.
```

## Fields

| Value                                                                                    | Description                                                                                |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| [Get](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablenodemode/get.md) | Determines the node's ports from the variable's kind. This is the default mode.@@@@\`      |
| [Set](/engine/6000.7/script-reference/unity/graphtoolkit/editor/variablenodemode/set.md) | Exposes an extra input port for writing a new value to the variable directly in the graph. |
