Interface IPortBuilder<T>
Base interface representing a generic port builder. Used in a builder pattern to configure and construct ports.
Namespace: Unity.GraphToolkit.Editor
Assembly: Unity.GraphToolkit.Editor.dll
Syntax
public interface IPortBuilder<T>
Type Parameters
Name | Description |
---|---|
T | The concrete builder type returned by configuration methods. |
Remarks
This interface supports a builder pattern, where each method returns the builder instance, allowing chained configuration of port settings before final construction using Build(). Use derived interfaces such as IInputPortBuilder or IOutputPortBuilder to build specific port types.
Examples
context.AddInputPort("MyInput")
.WithDataType(typeof(int))
.WithDisplayName("Input Value")
.Build();
Methods
Build()
Builds and returns the final IPort instance based on the current configuration of the builder.
Declaration
IPort Build()
Returns
Type | Description |
---|---|
IPort | The constructed IPort. |
Remarks
Call this method after setting all desired configuration options using the builder methods.
The builder captures options such as the port's data type, display name, connector style, and default value, if applicable.
This method finalizes the port and adds it to the graph. After calling Build()
, do not modify the builder further.
This method is typically called at the end of a chain.
Examples
context.AddInputPort("MyPort")
.WithDataType(typeof(float))
.WithDisplayName("My Float Port")
.WithConnectorUI(PortConnectorUI.Circle)
.Build();
WithConnectorUI(PortConnectorUI)
Configures the connector UI shape for the port being built.
Declaration
T WithConnectorUI(PortConnectorUI connectorUI)
Parameters
Type | Name | Description |
---|---|---|
PortConnectorUI | connectorUI | The PortConnectorUI shape to use. |
Returns
Type | Description |
---|---|
T | The current builder instance for method chaining. |
Remarks
Use this method to control the appearance of the port’s connector in the UI. The PortConnectorUI enum provides options such as Circle or Arrowhead. These shapes help users visually distinguish between different kinds of ports or flows. This setting affects only the UI and does not impact port behavior or connectivity. Call this method before Build() to ensure the selected style is applied to the constructed port.
WithDisplayName(string)
Configures the display name of the port being built.
Declaration
T WithDisplayName(string displayName)
Parameters
Type | Name | Description |
---|---|---|
string | displayName | The display name to assign to the port. |
Returns
Type | Description |
---|---|
T | The current builder instance for method chaining. |
Remarks
Use this method to assign a custom label to the port. This label appears in the user interface next to the port and helps clarify its purpose. Set the display name before calling Build(). The value does not affect functionality but improves usability and readability. If not set, the port name passed during creation (see: AddInputPort(string) and AddOutputPort(string)) is used as the fallback display name.