docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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 Node Port Example
    Input Node Port Example
    Bidirectional Node Port Example
    Connected Connected node
    Change event present Node Port Example

    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 Connected With ChangeEvent

    Port Read/Write (bidirectional)

    A port can read or write information, or do both (read/write).

    In the image below, you have:

    1. Bidirectional Port (read/write); Enable
    2. Write Port; Velocity
    3. Read Port; RPM

    Port ReadWrite

    Port order in nodes

    It's possible to reorder ports around in a node. The order of the ports doesn't affect runtime performance.

    Reorder ports

    To reset the node to the original port order:

    1. Right-click on the node.
    2. 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

    PortTypes 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

    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
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)