# GetVariables

> Retrieves all variables declared in the graph.

## Definition

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

## GetVariables()

Retrieves all variables declared in the graph.

```csharp
public IEnumerable<IVariable> GetVariables()
```

### Returns

| Type                                                                                                       | Description                                                                                                                         |
| ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| [IEnumerable\<IVariable>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) | An `IEnumerable` of all [IVariable](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable.md)s declared in the graph. |

### Remarks

Use this method to enumerate all [IVariable](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable.md)s declared in the graph. This list does not include variable nodes that reference variables. The collection reflects the variables as declared, in their order of creation. To get the variables in a specific order, use [Graph.GetVariables](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graph/getvariables.md).

## GetVariables(SortMethod)

Retrieves all variables declared in the graph in a specific order using [SortMethod](/engine/6000.6/script-reference/unity/graphtoolkit/editor/sortmethod.md).

```csharp
public IEnumerable<IVariable> GetVariables(SortMethod sort)
```

### Parameters

**** (\[SortMethod]\(/engine/6000.6/script-reference/unity/graphtoolkit/editor/sortmethod)): The sorting method.

### Returns

| Type                                                                                                       | Description                                                                                                                                                                                                                                           |
| ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [IEnumerable\<IVariable>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) | An `IEnumerable` of all [IVariable](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable.md)s declared in the graph, ordered using the provided [SortMethod](/engine/6000.6/script-reference/unity/graphtoolkit/editor/sortmethod.md). |

### Remarks

Use this method to enumerate all [IVariable](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable.md)s declared in the graph. This list does not include variable nodes that reference variables. The collection reflects the variables ordered using the provided [SortMethod](/engine/6000.6/script-reference/unity/graphtoolkit/editor/sortmethod.md).

* The [SortMethod.Creation](/engine/6000.6/script-reference/unity/graphtoolkit/editor/sortmethod/creation.md) option returns variables in their order of creation.

* The [SortMethod.Display](/engine/6000.6/script-reference/unity/graphtoolkit/editor/sortmethod/display.md) option returns variables in the order they are displayed in the blackboard.
