Class ComponentNode | Data Flow Graph | 0.16.0-preview.3
docs.unity3d.com
    Show / Hide Table of Contents

    Class ComponentNode

    A ComponentNode gives access to component data from a specific Entity in the rendering graph. IComponentData and IBufferElementData components are modeled as DataInput<TDefinition, TType> or DataOutput<TDefinition, TType>, and DataInput<TDefinition, TType> or DataOutput<TDefinition, TType> respectively.

    Using Input<TType>(IsComponent<TType>) and Output<TType>(IsComponent<TType>) you can create ports that can be connected to normal nodes, and the data will be readable and writable as usual in the rendering graph. Connect(NodeHandle, OutputPortID, NodeHandle, InputPortID, NodeSet.ConnectionType).

    The data will be committed after the returned from Update(JobHandle) is completed.

    ComponentNodes behave as normal nodes and thus any normal API on the NodeSet is accessible to them, with the exception that a ComponentNode does not have any ports predefined. GetPortDescription(NodeHandle)

    ComponentNodes have to be created through CreateComponentNode(Entity), and cannot be instantiated through Create<TDefinition>().

    A ComponentNode doesn't do anything itself and cannot be extended - it merely offers a topological dynamic read/write interface through ports to ECS.

    Inheritance
    Object
    NodeDefinition
    ComponentNode
    Inherited Members
    NodeDefinition.Set
    NodeDefinition.OnUpdate(UpdateContext)
    NodeDefinition.Init(InitContext)
    NodeDefinition.Destroy(DestroyContext)
    NodeDefinition.Dispose()
    NodeDefinition.HasStaticPortDescription
    NodeDefinition.GetStaticPortDescription()
    NodeDefinition.GetPortDescription(NodeHandle)
    NodeDefinition.EmitMessage<T, TNodeDefinition>(NodeHandle, MessageOutput<TNodeDefinition, T>, T)
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.DataFlowGraph
    Syntax
    public abstract class ComponentNode : NodeDefinition
    Remarks

    If the target Entity is destroyed, or if any referenced component data is missing, any I/O to this particular node or port is defaulted (but still continues to work). It's the user's responsibility to destroy the ComponentNode through Destroy(NodeHandle) (like any normal node), regardless of whether the target Entity exists or not.

    This API is only available if the hosting NodeSet was created with a companion ComponentSystemBase. NodeSet(ComponentSystemBase).

    When a DataOutput<TDefinition, TType> is linked to a ComponentNode's IBufferElementData, it is the user's responsibility to ensure that sizes match between DFG and ECS.

    PortArray<TPort> have no equivalent on ComponentNodes.

    In order to implement in place read-modify-write systems of ECS data, connections with Feedback need to be used in the following fashion.

    ComponentNodes appearing downstream in a graph and connected back to parent node(s) via Feedback connections can be understood to feed their "previous" component data to those parent nodes, and, update their component data at the end of any given Update(JobHandle). The "previous" component data will be the most current value from the ECS point of view, so this does not represent a frame delay.

    Therefore, if the desire is to model a graph that will read information from an Entity's component data, modify it, and then write it back to ECS, ComponentNodes should appear downstream in the graph and have Feedback connections to the upstream nodes.

    Methods

    Input(ComponentType)

    Create an InputPortID matching a particular ComponentType. An input to a ComponentNode represents a write back to the respective component on the Entity. If the component doesn't exist, the write back doesn't do anything. This is the untyped version of Input<TType>(IsComponent<TType>). Untyped port ids from ComponentNodes have overhead in usage together with Connect(NodeHandle, OutputPortID, NodeHandle, InputPortID, NodeSet.ConnectionType). To implement in-place read-modify-write of ECS data, see documentation of ComponentNode.

    Declaration
    public static InputPortID Input(ComponentType type)
    Parameters
    Type Name Description
    ComponentType type
    Returns
    Type Description
    InputPortID
    Exceptions
    Type Condition
    ArgumentException

    Thrown if the type doesn't have write access.

    Input<TType>(IsBuffer<TType>)

    This is a strongly typed version of Input(ComponentType), specifically for components implementing IBufferElementData. The data (coming from a Buffer<T>) can be connected to a DynamicBuffer<T> on a ComponentNode.

    Input<TType>(IsComponent<TType>)
    Declaration
    public static DataInput<ComponentNode, Buffer<TType>> Input<TType>(IsBuffer<TType> _ = default(IsBuffer<TType>))
        where TType : struct, IBufferElementData
    Parameters
    Type Name Description
    IsBuffer<TType> _
    Returns
    Type Description
    DataInput<ComponentNode, Buffer<TType>>
    Type Parameters
    Name Description
    TType

    Input<TType>(IsComponent<TType>)

    This is a strongly typed version of Input(ComponentType), with otherwise identical semantics.

    Declaration
    public static DataInput<ComponentNode, TType> Input<TType>(IsComponent<TType> _ = default(IsComponent<TType>))
        where TType : struct, IComponentData
    Parameters
    Type Name Description
    IsComponent<TType> _
    Returns
    Type Description
    DataInput<ComponentNode, TType>
    Type Parameters
    Name Description
    TType

    Output(ComponentType)

    Create an OutputPortID matching a particular ComponentType. An output from a ComponentNode represents a read from the respective component on the Entity. Anyone connected to a non-existing component on this Entity will read default values. This is the untyped version of Output<TType>(IsComponent<TType>). Untyped port ids from ComponentNodes have overhead in usage together with Connect(NodeHandle, OutputPortID, NodeHandle, InputPortID, NodeSet.ConnectionType). To implement in-place read-modify-write of ECS data, see documentation of ComponentNode.

    Declaration
    public static OutputPortID Output(ComponentType type)
    Parameters
    Type Name Description
    ComponentType type
    Returns
    Type Description
    OutputPortID
    Exceptions
    Type Condition
    ArgumentException

    Thrown if the type doesn't have read access.

    Output<TType>(IsBuffer<TType>)

    This is a strongly typed version of Output(ComponentType), specifically for components implementing IBufferElementData. The data (coming from a DynamicBuffer<T>) can be connected to a Buffer<T> on a NodeDefinition's IKernelPortDefinition.

    Output<TType>(IsComponent<TType>)
    Declaration
    public static DataOutput<ComponentNode, Buffer<TType>> Output<TType>(IsBuffer<TType> _ = default(IsBuffer<TType>))
        where TType : struct, IBufferElementData
    Parameters
    Type Name Description
    IsBuffer<TType> _
    Returns
    Type Description
    DataOutput<ComponentNode, Buffer<TType>>
    Type Parameters
    Name Description
    TType

    Output<TType>(IsComponent<TType>)

    This is a strongly typed version of Output(ComponentType), with otherwise identical semantics.

    Declaration
    public static DataOutput<ComponentNode, TType> Output<TType>(IsComponent<TType> _ = default(IsComponent<TType>))
        where TType : struct, IComponentData
    Parameters
    Type Name Description
    IsComponent<TType> _
    Returns
    Type Description
    DataOutput<ComponentNode, TType>
    Type Parameters
    Name Description
    TType
    In This Article
    • Methods
      • Input(ComponentType)
      • Input<TType>(IsBuffer<TType>)
      • Input<TType>(IsComponent<TType>)
      • Output(ComponentType)
      • Output<TType>(IsBuffer<TType>)
      • Output<TType>(IsComponent<TType>)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023