Struct CommonContext | Data Flow Graph | 0.18.0-preview.3
docs.unity3d.com
    Show / Hide Table of Contents

    Struct CommonContext

    The common portion of the API which appears on all contexts. Instances of InitContext, MessageContext, and UpdateContext can all be implicitly cast to this common context.

    Inherited Members
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.DataFlowGraph
    Syntax
    public struct CommonContext

    Fields

    Set

    The NodeSetAPI associated with this context.

    Declaration
    public readonly NodeSetAPI Set
    Field Value
    Type Description
    NodeSetAPI

    Properties

    Handle

    A handle uniquely identifying the current node.

    Declaration
    public NodeHandle Handle { get; }
    Property Value
    Type Description
    NodeHandle

    Methods

    EmitMessage<T, TNodeDefinition>(MessageOutput<TNodeDefinition, T>, T)

    Emit a message from yourself on a port. Everything connected to it will receive your message.

    Declaration
    public void EmitMessage<T, TNodeDefinition>(MessageOutput<TNodeDefinition, T> port, in T msg)
        where TNodeDefinition : NodeDefinition
    Parameters
    Type Name Description
    MessageOutput<TNodeDefinition, T> port
    T msg
    Type Parameters
    Name Description
    T
    TNodeDefinition

    EmitMessage<T, TNodeDefinition>(PortArray<MessageOutput<TNodeDefinition, T>>, Int32, T)

    Emit a message from yourself on a port array. Everything connected to it will receive your message.

    Declaration
    public void EmitMessage<T, TNodeDefinition>(PortArray<MessageOutput<TNodeDefinition, T>> port, int arrayIndex, in T msg)
        where TNodeDefinition : NodeDefinition
    Parameters
    Type Name Description
    PortArray<MessageOutput<TNodeDefinition, T>> port
    Int32 arrayIndex
    T msg
    Type Parameters
    Name Description
    T
    TNodeDefinition
    Exceptions
    Type Condition
    IndexOutOfRangeException

    Thrown if the index is out of range with respect to the port array.

    RegisterForUpdate()

    Registers the current node for regular updates every time Update() is called. This only takes effect after the next Update(). Update(UpdateContext) RemoveFromUpdate()

    Declaration
    public void RegisterForUpdate()
    Remarks

    A node will automatically be removed from the update list when it is destroyed.

    Exceptions
    Type Condition
    InvalidNodeDefinitionException

    Will be thrown if the current node does not support updating.

    InvalidOperationException

    Thrown if the current node is already registered for updating.

    RemoveFromUpdate()

    Deregisters the current node from updating every time Update() is called. This only takes effect after the next Update(). RegisterForUpdate()

    Declaration
    public void RemoveFromUpdate()
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if Handle is not registered for updating.

    SetKernelBufferSize<TGraphKernel>(TGraphKernel)

    Declaration
    [Obsolete("Renamed to UpdateKernelBuffers (RemovedAfter 2021-01-19)")]
    public void SetKernelBufferSize<TGraphKernel>(in TGraphKernel requestedSize)
        where TGraphKernel : struct, IGraphKernel
    Parameters
    Type Name Description
    TGraphKernel requestedSize
    Type Parameters
    Name Description
    TGraphKernel

    UpdateKernelBuffers<TGraphKernel>(TGraphKernel)

    Set the size of a Buffer<T> appearing in this node's IGraphKernel<TKernelData, TKernelPortDefinition>. Pass an instance of the node's IGraphKernel<TKernelData, TKernelPortDefinition> as the requestedSize parameter with Buffer<T> instances within it having been set using SizeRequest(Int32). Any Buffer<T> instances within the given struct that have not been set using SizeRequest(Int32) will be unaffected by the call.

    Declaration
    public void UpdateKernelBuffers<TGraphKernel>(in TGraphKernel requestedSize)
        where TGraphKernel : struct, IGraphKernel
    Parameters
    Type Name Description
    TGraphKernel requestedSize
    Type Parameters
    Name Description
    TGraphKernel

    UpdateKernelData<TKernelData>(TKernelData)

    Updates the associated TKernelData asynchronously, to be available in a IGraphKernel in the next render.

    Declaration
    public void UpdateKernelData<TKernelData>(in TKernelData data)
        where TKernelData : struct, IKernelData
    Parameters
    Type Name Description
    TKernelData data
    Type Parameters
    Name Description
    TKernelData

    UploadRequest<T>(NativeArray<T>, BufferUploadMethod)

    The return value should be used together with UpdateKernelBuffers<TGraphKernel>(TGraphKernel) to change the contents of a kernel buffer living on a IGraphKernel<TKernelData, TKernelPortDefinition>.

    Declaration
    public Buffer<T> UploadRequest<T>(NativeArray<T> inputMemory, BufferUploadMethod method = BufferUploadMethod.Copy)
        where T : struct
    Parameters
    Type Name Description
    NativeArray<T> inputMemory
    BufferUploadMethod method
    Returns
    Type Description
    Buffer<T>
    Type Parameters
    Name Description
    T
    Remarks

    This will resize the affected buffer to the same size as inputMemory. Failing to include the return value in a call to UpdateKernelBuffers<TGraphKernel>(TGraphKernel) is an error and will result in a memory leak.

    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