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
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.
Inherited Members
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.
Declaration
public static InputPortID Input(ComponentType type)
Parameters
Type | Name | Description |
---|---|---|
ComponentType | type |
Returns
Type | Description |
---|---|
InputPortID |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the |
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.
Declaration
public static OutputPortID Output(ComponentType type)
Parameters
Type | Name | Description |
---|---|---|
ComponentType | type |
Returns
Type | Description |
---|---|
OutputPortID |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the |
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 |