Interface Node.IPortDefinitionContext
Interface that provides methods to define input and output ports during OnDefinePorts(IPortDefinitionContext) execution.
Namespace: Unity.GraphToolkit.Editor
Assembly: Unity.GraphToolkit.Editor.dll
Syntax
public interface Node.IPortDefinitionContext
Remarks
Use this interface within OnDefinePorts(IPortDefinitionContext) to declare the ports a node exposes. Ports define how the node connects to other nodes by specifying inputs and outputs.
Methods
AddInputPort(string)
Adds a new input port.
Declaration
IInputPortBuilder AddInputPort(string portName)
Parameters
Type | Name | Description |
---|---|---|
string | portName | The unique identifier of the input port. |
Returns
Type | Description |
---|---|
IInputPortBuilder | An IInputPortBuilder 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 GetInputPortByName(string).
If WithDisplayName(string) is not used, this name is also used as the port's display label.
Warning: Changing a port's name will break any existing connections, as the name is used as the port's unique ID.
Use the returned builder to configure port properties and then call Build() to create the port.
Examples
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.
Declaration
IInputPortBuilder<T> AddInputPort<T>(string portName)
Parameters
Type | Name | Description |
---|---|---|
string | portName | The unique identifier of the input port. |
Returns
Type | Description |
---|---|
IInputPortBuilder<T> | An IInputPortBuilder<TData> to further configure the typed input port. |
Type Parameters
Name | Description |
---|---|
T | The data type of the 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 GetInputPortByName(string).
If WithDisplayName(string) is not used, this name is also used as the port's display label.
Warning: Changing a port's name will break any existing connections, as the name is used as the port's unique ID.
Use the returned builder to configure port properties and then call Build() to create the port.
Examples
var port = context.AddInputPort<string>("stringInput")
.WithDisplayName("String Input")
.WithDefaultValue("default text")
.Build();
AddOutputPort(string)
Adds a new output port with the specified name.
Declaration
IOutputPortBuilder AddOutputPort(string portName)
Parameters
Type | Name | Description |
---|---|---|
string | portName | The unique identifier of the output port. |
Returns
Type | Description |
---|---|
IOutputPortBuilder | An IOutputPortBuilder to further configure the output port. |
Remarks
portName
is used to identify the port. It must be unique among output ports on the node. This name is used as the ID when calling GetOutputPortByName(string).
If WithDisplayName(string) is not used, this name is also used as the port's display label.
Warning: Changing a port's name will break any existing connections, as the name is used as the port's unique ID.
Use the returned builder to configure port properties and then call Build() to create the port.
Examples
var port = context.AddOutputPort("myOutput")
.WithDisplayName("My Output Port")
.WithDataType(typeof(float))
.WithConnectorUI(PortConnectorUI.Arrowhead)
.Build();
AddOutputPort<T>(string)
Adds a new typed output port with the specified name.
Declaration
IOutputPortBuilder<T> AddOutputPort<T>(string portName)
Parameters
Type | Name | Description |
---|---|---|
string | portName | The unique identifier of the output port. |
Returns
Type | Description |
---|---|
IOutputPortBuilder<T> | An IOutputPortBuilder<TData> to further configure the typed output port. |
Type Parameters
Name | Description |
---|---|
T | The data type of the output port. |
Remarks
portName
is used to identify the port. It must be unique among output ports on the node. This name is used as the ID when calling GetOutputPortByName(string).
If WithDisplayName(string) is not used, this name is also used as the port's display label.
Warning: Changing a port's name will break any existing connections, as the name is used as the port's unique ID.
Use the returned builder to configure port properties and then call Build() to create the port.
Examples
var port = context.AddOutputPort<bool>("boolOutput")
.WithDisplayName("Boolean Output")
.Build();