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.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • RemoveComponent(NativeArray<Entity>, in ComponentTypeSet)
    • RemoveComponent(NativeArray<Entity>, ComponentType)
    • RemoveComponent(Entity, ComponentType)
    • RemoveComponent(SystemHandle, ComponentType)
    • RemoveComponent(Entity, in ComponentTypeSet)
    • RemoveComponent(EntityQuery, ComponentType)
    • RemoveComponent(EntityQuery, in ComponentTypeSet)
    • RemoveComponent<T>(Entity)
    • RemoveComponent<T>(SystemHandle)
    • RemoveComponent<T>(EntityQuery)
    • RemoveComponent<T>(NativeArray<Entity>)
    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)