Port
A port is the visual representation of information that's contained in a node as a field variable. The port can be read (input), write (output) or read and write.
A port is also described by its variable type. Ports connect together and are compatible by types. It's also possible to connect ports that can be converted to other types with the help of PortConverters
.
Port states
A port in SystemGraph can have the following states:
Port type | Example |
---|---|
Output | |
Input | |
Bidirectional | |
Connected | |
Change event present |
Connected Port
Displayed below, assuming these ports are contained to the left panel of a node. The table below uses input (read) and output (write) to describe the ports.
Connected Port with ChangeEvent
When a port is configured to receive a change event, a lightning badge appears below the port connector. The ChangeEvent
callback is set in the NodeRuntime
class that contains this port.
You can also add a custom callback handler to the port. In the Enable
callback of NodeRuntime
, add a delegate to the ChangeEvent
property of the port. The delegate contains no parameters and no return value.
To enable the callback of your node:
port.ChangeEvent += MyCallback;
To disable the callback of your node:
port.ChangeEvent -= MyCallback
Port Read/Write (bidirectional)
A port can read or write information, or do both (read/write).
In the image below, you have:
- Bidirectional Port (read/write); Enable
- Write Port; Velocity
- Read Port; RPM
Port order in nodes
It's possible to reorder ports around in a node. The order of the ports doesn't affect runtime performance.
To reset the node to the original port order:
- Right-click on the node.
- Select Reset Customization.
Add ports to NodeRuntime script
The ports of the node are defined within the NodeRuntime
scripts that you create. They use a special nomenclature to be registered to the SystemGraph.
For example, in your class you would have fields that are defined as such:
[Field("Input", PortDirection.Left, FieldExtra.Read), SerializeField]
private PortType<float> input = new PortType<float>();
The FieldExtra
enum dictates how the port will be used. Read/Write/ChangeEvent are possible values to set for this flag. Refer to the API documentation for more information.
PortType
PortType
s are wrappers that contain native types that can be exposed as ports to the SystemGraph nodes. These references are then linked through edges between nodes.
Nodes instantiate their own ports, but when ports are connected by an edge, they share a reference to the same PortType
. As such, no data copy is involved when connecting ports, data is shared instead.
PortType properties
- Write: Assigns a value to the embedded port type variable.
- Read: Reads a value from the embedded port type variable.
Port color reference
The following table lists hex colors for data types included with SystemGraph.
Port type | Hex Color |
---|---|
Bool | #C28383 |
Uint | #D2D7A2 |
Float or Single | #B490AE |
Double | #F490AE |
Quaternion | #B8ABD7 |
GameObject | #94B7C1 |
AnimationCurve | #D3C292 |
CodecName | #CBA88E |
Vector2 | #8FCDB2 |
Vector3 | #99CC94 |
Vector4 | #BCD095 |
EncodedData | #C28383 |
CapturedData | #B490AE |