# AddSubgraphNode(Graph, Vector2)

> Creates and adds a new subgraph node referencing an existing Graph asset.

## Definition

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

```csharp
public ISubgraphNode AddSubgraphNode(Graph subgraph, Vector2 position)
```

### Parameters

**** (\[Graph]\(/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph)): The Graph asset to reference.**** (\[Vector2]\(/engine/6000.7/script-reference/unityengine/vector2)): The position of the node.

### Returns

| Type                                                                                        | Description                      |
| ------------------------------------------------------------------------------------------- | -------------------------------- |
| [ISubgraphNode](/engine/6000.7/script-reference/unity/graphtoolkit/editor/isubgraphnode.md) | The newly created subgraph node. |

### Remarks

Enclose this method with [Graph.UndoBeginRecordGraph](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/undobeginrecordgraph.md) and [Graph.UndoEndRecordGraph](/engine/6000.7/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.
