docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method SetComponentObject

    SetComponentObject(EntityQuery, object)

    Records a command to set a hybrid component value for all entities matching a query.

    Declaration
    public void SetComponentObject(EntityQuery entityQuery, object componentData)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The query specifying which entities to set the component value for.

    object componentData

    The component object 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.

     At playback, this command throws an error if one of these entities is destroyed before playback,
     if any entity has the <xref href="Unity.Entities.Prefab" data-throw-if-not-resolved="false"></xref> tag, or if any entity does not have the component type at playback.
     Playback Entities which already have the component type will have the component set to the value.
    
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown in playback if one or more of the entities does not have the component type or has been destroyed. (With safety checks disabled, playback will perform invalid and unsafe memory access.).

    NullReferenceException

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

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    ArgumentNullException

    Throws if componentData is null.

    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)