# AddInputPort

> Adds a new input port.

## Definition

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

## AddInputPort(string)

Adds a new input port.

```csharp
IInputPortBuilder AddInputPort(string portName)
```

### Parameters

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

### Returns

| Type                                                                                                | Description                                                                                                                                 |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [IInputPortBuilder](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iinputportbuilder.md) | An [IInputPortBuilder](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iinputportbuilder.md) to further configure the input port. |

### Remarks

`portName` is used to identify the port. It must be unique among input ports and node options on the node. This name is used as the ID when calling [Node.GetInputPortByName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/node/getinputportbyname.md). If [IPortBuilder\<T>.WithDisplayName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iportbuilder1/withdisplayname.md) is not used, this name is also used as the port's display label.

**Warning**: Changing a port's name breaks any existing connections, because the name is used as the port's unique ID.

Use the returned builder to configure port properties and then call [IPortBuilder\<T>.Build()](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iportbuilder1/build.md) to create the port.

### Examples

```csharp
var port = context.AddInputPort("myInput")
    .WithDisplayName("My Input Port")
    .WithDataType<int>()
    .WithConnectorUI(PortConnectorUI.Circle)
    .Build();
```

## AddInputPort\<T>(string)

Adds a new typed input port with the specified name.

```csharp
IInputPortBuilder<T> AddInputPort<T>(string portName)
```

### Parameters

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

### Returns

| Type                                                                                                    | Description                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [IInputPortBuilder\<T>](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iinputportbuilder.md) | An [IInputPortBuilder\<TData>](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iinputportbuilder1.md) to further configure the typed input port. |

### Remarks

`portName` is used to identify the port. It must be unique among input ports on the node. This name is used as the ID when calling [Node.GetInputPortByName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/node/getinputportbyname.md). If [IPortBuilder\<T>.WithDisplayName](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iportbuilder1/withdisplayname.md) is not used, this name is also used as the port's display label.

**Warning**: Changing a port's name breaks any existing connections, because the name is used as the port's unique ID.

Use the returned builder to configure port properties and then call [IPortBuilder\<T>.Build()](/engine/6000.5/script-reference/unity/graphtoolkit/editor/iportbuilder1/build.md) to create the port.

### Examples

```csharp
var port = context.AddInputPort<string>("stringInput")
    .WithDisplayName("String Input")
    .WithDefaultValue("default text")
    .Build();
```
