# AddOption

> Adds a new node option.

## Definition

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

## AddOption(string, Type)

Adds a new node option.

```csharp
IOptionBuilder 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                                                                                                                       |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| [IOptionBuilder](/engine/6000.5/script-reference/unity/graphtoolkit/editor/ioptionbuilder.md) | An [IOptionBuilder](/engine/6000.5/script-reference/unity/graphtoolkit/editor/ioptionbuilder.md) to further configure the option. |

### Remarks

`name` is used to identify the option. It must be unique among ports and options on the node. This name is used as the ID when calling [Node.GetNodeOptionByName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/node/getnodeoptionbyname.md). If [IOptionBuilder.WithDisplayName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/ioptionbuilder/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 node option.

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

### Parameters

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

### Returns

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

### Remarks

`name` is used to identify the option. It must be unique among ports and options on the node. This name is used as the ID when calling [Node.GetNodeOptionByName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/node/getnodeoptionbyname.md). If [IOptionBuilder\<TData>.WithDisplayName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/ioptionbuilder1/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()
}
```
