# CreateLocalSubgraphNode

> Creates and adds a new local subgraph node.

## Definition

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

## CreateLocalSubgraphNode(Type, string, Vector2)

Creates and adds a new local subgraph node.

```csharp
public ISubgraphNode CreateLocalSubgraphNode(Type subgraphType, string name, Vector2 position)
```

### Parameters

**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): The type of the subgraph to create.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the local subgraph.**** (\[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.

## CreateLocalSubgraphNode\<T>(string, Vector2)

Creates and adds a new local subgraph node.

```csharp
public ISubgraphNode CreateLocalSubgraphNode<TSubGraph>(string name, Vector2 position) where TSubGraph : Graph, new()
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the local subgraph.**** (\[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.
