docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method AddComponent

    AddComponent(ForEachLambdaJobDescription, ComponentType)

    Adds a component to a set of entities selected by the query you have defined using WithAny/WithAll/WithNone

    Declaration
    public static void AddComponent(this ForEachLambdaJobDescription description, ComponentType componentType)
    Parameters
    Type Name Description
    ForEachLambdaJobDescription description

    The target object

    ComponentType componentType

    The type of component to add.

    Remarks

    Can add any kind of component.

    Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.

    The added components have the default values for the type.

    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.

    AddComponent(ForEachLambdaJobDescription, in ComponentTypeSet)

    Adds components to a set of entities selected by the query you have defined using WithAny/WithAll/WithNone

    Declaration
    public static void AddComponent(this ForEachLambdaJobDescription description, in ComponentTypeSet componentTypes)
    Parameters
    Type Name Description
    ForEachLambdaJobDescription description

    The target object

    ComponentTypeSet componentTypes

    The type of components to add.

    Remarks

    Can add any kinds of components.

    The added components have the default values for the type.

    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.

    AddComponent<T>(ForEachLambdaJobDescription)

    Adds a component to a set of entities selected by the query you have defined using WithAny/WithAll/WithNone

    Declaration
    public static void AddComponent<T>(this ForEachLambdaJobDescription description) where T : unmanaged, IComponentData
    Parameters
    Type Name Description
    ForEachLambdaJobDescription description

    The target object

    Type Parameters
    Name Description
    T

    The type of component to add.

    Remarks

    Can add any kind of component except chunk components.

    Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.

    The added components have the default values for the type.

    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.

    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)