# AddOption

> Adds a new state option.

## Definition

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

## AddOption(string, Type)

Adds a new state option.

```csharp
IStateOptionBuilder AddOption(string name, Type dataType)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The unique identifier of the option.**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): The data type of the option.

### Returns

| Type                                                                                                    | Description                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [IStateOptionBuilder](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istateoptionbuilder.md) | An [IStateOptionBuilder](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istateoptionbuilder.md) to further configure the option. |

### Remarks

`name` is used to identify the option. It must be unique among the options on the state. This name is used as the ID when calling [State.GetOptionByName](/engine/6000.7/script-reference/unity/graphtoolkit/editor/state/getoptionbyname.md). If [IStateOptionBuilder.WithDisplayName](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istateoptionbuilder/withdisplayname.md) is not used, this name is also used as the option's display label.

### Examples

```csharp
protected override void OnDefineOptions(IOptionDefinitionContext context)
{
    context.AddOption("MyOption", typeof(int))
        .WithDefaultValue(2)
        .Delayed();
}
```

## AddOption\<T>(string)

Adds a new state option.

```csharp
IStateOptionBuilder<TData> AddOption<TData>(string name)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The unique identifier of the option.

### Returns

| Type                                                                                                        | Description                                                                                                                                 |
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [IStateOptionBuilder\<T>](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istateoptionbuilder.md) | An [IStateOptionBuilder](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istateoptionbuilder.md) to further configure the option. |

### Remarks

`name` is used to identify the option. It must be unique among the options on the state. This name is used as the ID when calling [State.GetOptionByName](/engine/6000.7/script-reference/unity/graphtoolkit/editor/state/getoptionbyname.md). If [IStateOptionBuilder\<TData>.WithDisplayName](/engine/6000.7/script-reference/unity/graphtoolkit/editor/istateoptionbuilder1/withdisplayname.md) is not used, this name is also used as the option's display label.

### Examples

```csharp
protected override void OnDefineOptions(IOptionDefinitionContext context)
{
    context.AddOption<int>("MyOption")
        .WithDefaultValue(2)
        .Delayed();
}
```
