docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method RemoveComponent

    RemoveComponent<T>(Entity)

    Records a command to remove component of type T from an entity.

    Declaration
    public void RemoveComponent<T>(Entity e)
    Parameters
    Type Name Description
    Entity e

    The entity to have the component removed.

    Type Parameters
    Name Description
    T

    The type of component to remove.

    Remarks

    At playback, it's not an error if the entity doesn't have component T. Will throw an error if this entity is destroyed before playback, if this entity is still deferred, or if T is type Entity or Prefab.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent<T>(NativeArray<Entity>)

    Records a command to remove component of type T from a NativeArray of entities.

    Declaration
    public void RemoveComponent<T>(NativeArray<Entity> entities)
    Parameters
    Type Name Description
    NativeArray<Entity> entities

    The NativeArray of entities to have the component removed.

    Type Parameters
    Name Description
    T

    The type of component to remove.

    Remarks

    At playback, it's not an error if any entity doesn't have component T. Will throw an error if one of these entities is destroyed before playback, if one of these entities is still deferred, or if T is type Entity or Prefab.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent(Entity, ComponentType)

    Records a command to remove a component from an entity.

    Declaration
    public void RemoveComponent(Entity e, ComponentType componentType)
    Parameters
    Type Name Description
    Entity e

    The entity to have the component removed.

    ComponentType componentType

    The type of component to remove.

    Remarks

    At playback, it's not an error if the entity doesn't have the component type. Will throw an error if this entity is destroyed before playback, if this entity is still deferred, or if the component type is Entity or Prefab.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent(NativeArray<Entity>, ComponentType)

    Records a command to remove one or more components from a NativeArray of entities.

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

    The NativeArray of entities to have the component removed.

    ComponentType componentType

    The type of component to remove.

    Remarks

    At playback, it's not an error if any entity doesn't have the component type. Will throw an error if one of these entities is destroyed before playback, if one of these entities is still deferred, or if the component type is Entity or Prefab.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent(Entity, in ComponentTypeSet)

    Records a command to remove one or more components from an entity.

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

    The entity to have components removed.

    ComponentTypeSet componentTypeSet

    The types of components to remove.

    Remarks

    At playback, it's not an error if the entity doesn't have one of the component types. Will throw an error if this entity is destroyed before playback, if this entity is still deferred, or if any of the component types are Entity or Prefab.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent(NativeArray<Entity>, in ComponentTypeSet)

    Records a command to remove one or more components from a NativeArray of entities.

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

    The NativeArray of entities to have components removed.

    ComponentTypeSet componentTypeSet

    The types of components to remove.

    Remarks

    At playback, it's not an error if any entity doesn't have one of the component types. Will throw an error if one of these entities is destroyed before playback, if one of these entities is still deferred, or if any of the component types are Entity or Prefab.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent(EntityQuery, ComponentType, EntityQueryCaptureMode)

    Records a command to remove a component from all entities matching a query.

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

    The query specifying the entities from which the component is removed.

    ComponentType componentType

    The types of component to remove.

    EntityQueryCaptureMode queryCaptureMode

    Controls when the entities matching entityQuery are computed and captured.

    Remarks

    Does not affect entities already missing the component.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent(EntityQuery, ComponentType)

    Obsolete. Use RemoveComponent(EntityQuery, ComponentType, EntityQueryCaptureMode) instead.

    Declaration
    [Obsolete("This method now takes an extra parameter to control when the query is evaluated. To preserve the current semantics, use EntityQueryCaptureMode.AtRecord (RemovedAfter Entities 2.0)")]
    public void RemoveComponent(EntityQuery entityQuery, ComponentType componentType)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The query specifying the entities to which the component is added.

    ComponentType componentType

    The type of component to add.

    RemoveComponent<T>(EntityQuery, EntityQueryCaptureMode)

    Records a command to remove a component from all entities matching a query.

    Declaration
    public void RemoveComponent<T>(EntityQuery entityQuery, EntityQueryCaptureMode queryCaptureMode)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The query specifying the entities from which the component is removed.

    EntityQueryCaptureMode queryCaptureMode

    Controls when the entities matching entityQuery are computed and captured.

    Type Parameters
    Name Description
    T

    The type of component to remove.

    Remarks

    Does not affect entities already missing the component.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent<T>(EntityQuery)

    Obsolete. Use RemoveComponent<T>(EntityQuery, EntityQueryCaptureMode) instead.

    Declaration
    [Obsolete("This method now takes an extra parameter to control when the query is evaluated. To preserve the current semantics, use EntityQueryCaptureMode.AtRecord (RemovedAfter Entities 2.0)")]
    public void RemoveComponent<T>(EntityQuery entityQuery)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The query specifying the entities to which the component is added.

    Type Parameters
    Name Description
    T

    RemoveComponent(EntityQuery, in ComponentTypeSet, EntityQueryCaptureMode)

    Records a command to remove multiple components from all entities matching a query.

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

    The query specifying the entities from which the components are removed.

    ComponentTypeSet componentTypeSet

    The types of components to remove.

    EntityQueryCaptureMode queryCaptureMode

    Controls when the entities matching entityQuery are computed and captured.

    Remarks

    The set of entities matching the query is 'captured' in the method call, and the recorded command stores an array of all these entities.

     Some matching entities may already be missing some or all of the specified components. After this operation, all matching entities will have none of the components.
    
     At playback, this command throws an error if one of these entities is destroyed before playback. (With safety checks enabled, an exception is thrown. Without safety checks,
     playback will perform invalid and unsafe memory access.)
    
    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    RemoveComponent(EntityQuery, in ComponentTypeSet)

    Obsolete. Use RemoveComponent(EntityQuery,ComponentTypeSet,EntityQueryCaptureMode) instead.

    Declaration
    [Obsolete("This method now takes an extra parameter to control when the query is evaluated. To preserve the current semantics, use EntityQueryCaptureMode.AtRecord (RemovedAfter Entities 2.0)")]
    public void RemoveComponent(EntityQuery entityQuery, in ComponentTypeSet componentTypeSet)
    Parameters
    Type Name Description
    EntityQuery entityQuery

    The query specifying the entities from which the components are removed.

    ComponentTypeSet componentTypeSet

    The types of components to remove.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    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)