docs.unity.cn
    Show / Hide Table of Contents

    Method AddChunkComponentData

    AddChunkComponentData<T>(ForEachLambdaJobDescription, T)

    Adds a chunk component to each of the chunks identified by the query you have defined using WithAny/WithAll/WithNone and sets the component values.

    Declaration
    public static void AddChunkComponentData<T>(this ForEachLambdaJobDescription description, T componentData)
        where T : struct, IComponentData
    Parameters
    Type Name Description
    Unity.Entities.CodeGeneratedJobForEach.ForEachLambdaJobDescription description

    The target object

    T componentData

    The data to set.

    Type Parameters
    Name Description
    T

    The type of component, which must implement IComponentData.

    Remarks

    This function finds all chunks whose archetype satisfies the EntityQuery and adds the specified component to them.

    A chunk component is common to all entities in a chunk. You can access a chunk IComponentData instance through either the chunk itself or through an entity stored in that chunk.

    Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before adding the component and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023