# IVariable

> Interface for a graph variable.

## Definition

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

```csharp
public interface IVariable
```

## Remarks

Variables are data containers that are accessible throughout a graph. You can manage variables in the Blackboard and reference them with variable nodes. A variable has a name, a data type, a kind that defines its visibility within subgraphs, and an optional default value. Use [IVariable.TryGetDefaultValue](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/trygetdefaultvalue.md) to retrieve the default value if one exists. Variables are distinct from variable nodes. However, you can drag variables onto the graph canvas, where they are instantiated as variable nodes.

## Properties

| Property                                                                                            | Description                                                                                                                  |
| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| [DataType](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/datatype.md)         | Gets or sets the data type of the variable.                                                                                  |
| [Graph](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/graph.md)               | The [IVariable.Graph](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/graph.md) that owns this variable. |
| [ID](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/id.md)                     | The globally unique identifier for this variable declaration.                                                                |
| [IsConnected](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/isconnected.md)   | Whether the variable has at least one connected variable node in the graph.                                                  |
| [Name](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/name.md)                 | Gets or sets the name of the variable.                                                                                       |
| [NodeCount](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/nodecount.md)       | The number of variable nodes associated with this variable in the graph.                                                     |
| [VariableKind](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/variablekind.md) | Gets or sets the kind of the variable, such as Local, Input, or Output.                                                      |

## Methods

| Method                                                                                                          | Description                                                 |
| --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [GetNodes](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/getnodes.md)                     | Retrieves all variable nodes associated with this variable. |
| [RemoveFromGraph](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/removefromgraph.md)       | Removes the current variable from its graph.                |
| [TryGetDefaultValue](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/trygetdefaultvalue.md) | Retrieves the default value of the variable.                |
| [TrySetDefaultValue](/engine/6000.6/script-reference/unity/graphtoolkit/editor/ivariable/trysetdefaultvalue.md) | Sets the default value of the variable.                     |
