# GetSubgraphAsStateMachine()

> Retrieves the subgraph linked to this state as a StateMachine.

## Definition

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

```csharp
StateMachine GetSubgraphAsStateMachine()
```

### Returns

| Type                                                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [StateMachine](/engine/6000.7/script-reference/unity/graphtoolkit/editor/statemachine.md) | The [StateMachine](/engine/6000.7/script-reference/unity/graphtoolkit/editor/statemachine.md) instance that this state references, or `null` if the referenced subgraph is a regular [Graph](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph.md) (use [ISubgraphState.GetSubgraphAsGraph](/engine/6000.7/script-reference/unity/graphtoolkit/editor/isubgraphstate/getsubgraphasgraph.md) instead) or no subgraph is set. |
