Class EntityManagerManagedComponentExtensions | Entities | 0.10.0-preview.6
docs.unity3d.com
    Show / Hide Table of Contents

    Class EntityManagerManagedComponentExtensions

    Inheritance
    Object
    EntityManagerManagedComponentExtensions
    Namespace: Unity.Entities
    Syntax
    public static class EntityManagerManagedComponentExtensions

    Methods

    AddChunkComponentData<T>(EntityManager, Entity)

    Adds a chunk component to the specified entity.

    Declaration
    public static void AddChunkComponentData<T>(this EntityManager manager, Entity entity)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    Entity entity

    The entity.

    Type Parameters
    Name Description
    T

    The type of component, which must implement IComponentData.

    Remarks

    Adding a chunk component to an entity changes that entity's archetype and results in the entity being moved to a different chunk, either one that already has an archetype containing the chunk component or a new chunk.

    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. In either case, getting or setting the component reads or writes the same data.

    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.

    AddChunkComponentData<T>(EntityManager, EntityQuery, T)

    Adds a component to each of the chunks identified by a EntityQuery and set the component values.

    Declaration
    public static void AddChunkComponentData<T>(this EntityManager manager, EntityQuery entityQuery, T componentData)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    EntityQuery entityQuery

    The EntityQuery identifying the chunks to modify.

    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.

    AddComponentData<T>(EntityManager, Entity, T)

    Adds a component to an entity and set the value of that component.

    Declaration
    public static void AddComponentData<T>(this EntityManager manager, Entity entity, T componentData)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    Entity entity

    The entity.

    T componentData

    The data to set.

    Type Parameters
    Name Description
    T

    The type of component.

    Remarks

    Adding a component changes an entity's archetype and results in the entity being moved to a different 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.

    GetChunkComponentData<T>(EntityManager, ArchetypeChunk)

    Gets the value of a chunk component.

    Declaration
    public static T GetChunkComponentData<T>(this EntityManager manager, ArchetypeChunk chunk)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    ArchetypeChunk chunk

    The chunk.

    Returns
    Type Description
    T

    A struct of type T containing the component value.

    Type Parameters
    Name Description
    T

    The component type.

    Remarks

    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.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the ArchetypeChunk object is invalid.

    GetChunkComponentData<T>(EntityManager, Entity)

    Gets the value of chunk component for the chunk containing the specified entity.

    Declaration
    public static T GetChunkComponentData<T>(this EntityManager manager, Entity entity)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    Entity entity

    The entity.

    Returns
    Type Description
    T

    A struct of type T containing the component value.

    Type Parameters
    Name Description
    T

    The component type.

    Remarks

    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.

    GetComponentData<T>(EntityManager, Entity)

    Gets the value of a component for an entity.

    Declaration
    public static T GetComponentData<T>(this EntityManager manager, Entity entity)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    Entity entity

    The entity.

    Returns
    Type Description
    T

    A struct of type T containing the component value.

    Type Parameters
    Name Description
    T

    The type of component to retrieve.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the component type has no fields.

    SetChunkComponentData<T>(EntityManager, ArchetypeChunk, T)

    Sets the value of a chunk component.

    Declaration
    public static void SetChunkComponentData<T>(this EntityManager manager, ArchetypeChunk chunk, T componentValue)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    ArchetypeChunk chunk

    The chunk to modify.

    T componentValue

    The component data to set.

    Type Parameters
    Name Description
    T

    The component type.

    Remarks

    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.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the ArchetypeChunk object is invalid.

    SetComponentData<T>(EntityManager, Entity, T)

    Sets the value of a component of an entity.

    Declaration
    public static void SetComponentData<T>(this EntityManager manager, Entity entity, T componentData)
        where T : class, IComponentData
    Parameters
    Type Name Description
    EntityManager manager
    Entity entity

    The entity.

    T componentData

    The data to set.

    Type Parameters
    Name Description
    T

    The component type.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the component type has no fields.

    In This Article
    • Methods
      • AddChunkComponentData<T>(EntityManager, Entity)
      • AddChunkComponentData<T>(EntityManager, EntityQuery, T)
      • AddComponentData<T>(EntityManager, Entity, T)
      • GetChunkComponentData<T>(EntityManager, ArchetypeChunk)
      • GetChunkComponentData<T>(EntityManager, Entity)
      • GetComponentData<T>(EntityManager, Entity)
      • SetChunkComponentData<T>(EntityManager, ArchetypeChunk, T)
      • SetComponentData<T>(EntityManager, Entity, T)
    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