docs.unity3d.com
    Show / Hide Table of Contents

    Method SetSharedComponentForEntityQuery

    SetSharedComponentForEntityQuery<T>(EntityQuery, T)

    Records a command to set a shared component value on all entities matching a query.

    Declaration
    public void SetSharedComponentForEntityQuery<T>(EntityQuery entityQuery, T component)
        where T : struct, ISharedComponentData
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The query specifying which entities to add the component value to.

    T component

    The component value to add.

    Type Parameters
    Name Description
    T

    The type of shared component to set.

    Remarks

    The set of entities matching the query is 'captured' in the method call, and the recorded command stores an array of all these entities.

    Fails if any of the entities do not have the type of shared component. [todo: should it be required that the component type is included in the query?]

    Behavior at Playback: Will throw an error if one of these entities is destroyed before playback. (With safety checks enabled, an exception is thrown. Without safety checks, playback will perform invalid and unsafe memory access.)

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    Back to top
    Terms of use
    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