# AddVariableNode(IVariable, Vector2)

> Creates and adds a new variable node referencing an existing variable.

## Definition

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

```csharp
public IVariableNode AddVariableNode(IVariable variable, Vector2 position)
```

### Parameters

**** (\[IVariable]\(/engine/6000.5/script-reference/unity/graphtoolkit/editor/ivariable)): The variable to reference. Must belong to this graph.**** (\[Vector2]\(/engine/6000.5/script-reference/unityengine/vector2)): The position of the node.

### Returns

| Type                                                                                        | Description                      |
| ------------------------------------------------------------------------------------------- | -------------------------------- |
| [IVariableNode](/engine/6000.5/script-reference/unity/graphtoolkit/editor/ivariablenode.md) | The newly created variable node. |

### Remarks

Enclose this method with [Graph.UndoBeginRecordGraph](/engine/6000.5/script-reference/unity/graphtoolkit/editor/graph/undobeginrecordgraph.md) and [Graph.UndoEndRecordGraph](/engine/6000.5/script-reference/unity/graphtoolkit/editor/graph/undoendrecordgraph.md) to add this operation to the undo stack and to update the graph view with the changes.
