docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method RemoveComponent

    RemoveComponent(NativeArray<Entity>, in ComponentTypeSet)

    Removes multiple components from a specified colleciton of entities.

    Declaration
    public void RemoveComponent(NativeArray<Entity> entities, in ComponentTypeSet componentTypeSet)
    Parameters
    Type Name Description
    NativeArray<Entity> entities

    The collection of entities to modify.

    ComponentTypeSet componentTypeSet

    The types of components to remove.

    Remarks

    You can use this method to remove a component from an Entity

    It's OK if some or all of the components to remove are already missing from the entity.

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

    If any of the types are a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    RemoveComponent(NativeArray<Entity>, ComponentType)

    Remove a component from a set of entities.

    Declaration
    public void RemoveComponent(NativeArray<Entity> entities, ComponentType componentType)
    Parameters
    Type Name Description
    NativeArray<Entity> entities

    An array of Entity objects.

    ComponentType componentType

    The type of component to remove.

    Remarks

    Can remove any kind of component.

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

    If componentType is a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the chunk. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    Exceptions
    Type Condition
    ArgumentException

    The entities array refers to an entity that does not exist.

    RemoveComponent(Entity, ComponentType)

    Removes a component from an entity.

    Declaration
    public bool RemoveComponent(Entity entity, ComponentType componentType)
    Parameters
    Type Name Description
    Entity entity

    The entity to modify.

    ComponentType componentType

    The type of component to remove.

    Returns
    Type Description
    bool

    True if the component was removed successfully.

    Remarks

    Can remove any kind of component.

    Returns false if the entity already does not have the specified component, or if the entity does not exist.

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

    If componentType is a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    RemoveComponent(SystemHandle, ComponentType)

    Removes a component from an entity associated with a system.

    Declaration
    public bool RemoveComponent(SystemHandle system, ComponentType componentType)
    Parameters
    Type Name Description
    SystemHandle system

    The system handle.

    ComponentType componentType

    The type of component to remove.

    Returns
    Type Description
    bool

    True if the component was removed successfully.

    Remarks

    Can remove any kind of component.

    Returns false if the entity already does not have the specified component, or if the entity does not exist.

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

    If componentType is a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    RemoveComponent(Entity, in ComponentTypeSet)

    Removes multiple components from an entity.

    Declaration
    public void RemoveComponent(Entity entity, in ComponentTypeSet componentTypeSet)
    Parameters
    Type Name Description
    Entity entity

    The entity to modify.

    ComponentTypeSet componentTypeSet

    The types of components to remove.

    Remarks

    You can use this method to remove a component from an Entity

    It's OK if some or all of the components to remove are already missing from the entity, or if the target entity does not exist.

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

    If any of the types are a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    RemoveComponent(EntityQuery, ComponentType)

    Removes a component from a set of entities defined by an EntityQuery.

    Declaration
    public void RemoveComponent(EntityQuery entityQuery, ComponentType componentType)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The EntityQuery defining the entities to modify.

    ComponentType componentType

    The type of component to remove.

    Remarks

    Can remove any kind of component.

    It's OK if some or all of the components to remove are already missing from some or all of the entities.

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

    If componentType is a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    RemoveComponent(EntityQuery, in ComponentTypeSet)

    Removes a set of components from a set of entities defined by an EntityQuery.

    Declaration
    public void RemoveComponent(EntityQuery entityQuery, in ComponentTypeSet componentTypeSet)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The EntityQuery defining the entities to modify.

    ComponentTypeSet componentTypeSet

    The types of components to add.

    Remarks

    You can use this method to remove a component from an Entity

    It's OK if some or all of the components to remove are already missing from some or all of the entities.

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

    If any of the types are a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    RemoveComponent<T>(Entity)

    Removes a component from an entity.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[] { typeof(BurstCompatibleComponentData) })]
    public bool RemoveComponent<T>(Entity entity)
    Parameters
    Type Name Description
    Entity entity

    The entity.

    Returns
    Type Description
    bool

    True if the component was removed successfully.

    Type Parameters
    Name Description
    T

    The type of component to remove.

    Remarks

    Can remove any kind of component except chunk components.

    Returns false if the entity was already missing the component.

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

    If T is a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    RemoveComponent<T>(SystemHandle)

    Removes a component from an entity associated with a system.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[] { typeof(BurstCompatibleComponentData) })]
    public bool RemoveComponent<T>(SystemHandle system)
    Parameters
    Type Name Description
    SystemHandle system

    The system handle.

    Returns
    Type Description
    bool

    True if the component was removed successfully.

    Type Parameters
    Name Description
    T

    The type of component to remove.

    Remarks

    Can remove any kind of component except chunk components.

    Returns false if the entity was already missing the component.

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

    If T is a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    Exceptions
    Type Condition
    ArgumentException

    The Entity does not exist.

    RemoveComponent<T>(EntityQuery)

    Removes a component from a set of entities defined by a EntityQuery.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[] { typeof(BurstCompatibleComponentData) })]
    public void RemoveComponent<T>(EntityQuery entityQuery)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The EntityQuery defining the entities to modify.

    Type Parameters
    Name Description
    T

    The type of component to remove.

    Remarks

    Can remove any kind of component except chunk components.

    It's OK if the component to remove is already missing from some or all of the entities.

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

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    RemoveComponent<T>(NativeArray<Entity>)

    Removes a component from a set of entities.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[] { typeof(BurstCompatibleComponentData) })]
    public void RemoveComponent<T>(NativeArray<Entity> entities)
    Parameters
    Type Name Description
    NativeArray<Entity> entities

    An array identifying the entities to modify.

    Type Parameters
    Name Description
    T

    The type of component to remove.

    Remarks

    Can remove any kind of component except chunk components.

    It's OK if the component to remove is already missing from some or all of the entities.

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

    If T is a managed component which implements IDisposable, this operation will invoke Dispose() on the component value.

    Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before removing the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

    In This Article
    Back to top
    Copyright © 2025 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)