# GetState(int)

> Retrieves a state in the state machine by its index.

## Definition

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

```csharp
public IState GetState(int index)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The zero-based index of the state to retrieve.

### Returns

| Type                                                                          | Description                                                                                               |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [IState](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istate.md) | The [IState](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istate.md) at the specified index. |

### Remarks

Use this method to access a state based on its creation order in the state machine. The index is zero-based and must be within range (see: [StateMachine.StateCount](/engine/6000.7/script-reference/unity/graphtoolkit/editor/statemachine/statecount.md)).
