Documentation

Unity Engine


Unity Engine


RemoveComponent

Records a command to remove component of type T from an entity.
Read time 5 minutesLast updated 3 days ago

Definition

  • Type: Method
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule

RemoveComponent<T>(Entity)

Records a command to remove component of type T from an entity.
public void RemoveComponent<T>(Entity e)

Parameters

The entity to have the component removed.

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, or if T is type Entity or Prefab.

RemoveComponent<T>(NativeArray<Entity>)

Records a command to remove component of type T from a NativeArray of entities.
public void RemoveComponent<T>(NativeArray<Entity> entities)

Parameters

The NativeArray of entities to have the component removed.

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, or if T is type Entity or Prefab.

RemoveComponent(Entity, ComponentType)

Records a command to remove a component from an entity.
public void RemoveComponent(Entity e, ComponentType componentType)

Parameters

The entity to have the component removed.

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, or if the component type is Entity or Prefab.

RemoveComponent(NativeArray<Entity>, ComponentType)

Records a command to remove one or more components from a NativeArray of entities.
public void RemoveComponent(NativeArray<Entity> entities, ComponentType componentType)

Parameters

The NativeArray of entities to have the component removed.

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, or if the component type is Entity or Prefab.

RemoveComponent(Entity, ComponentTypeSet)

Records a command to remove one or more components from an entity.
public void RemoveComponent(Entity e, in ComponentTypeSet componentTypeSet)

Parameters

The entity to have components removed.

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, or if any of the component types are Entity or Prefab.

RemoveComponent(NativeArray<Entity>, ComponentTypeSet)

Records a command to remove one or more components from a NativeArray of entities.
public void RemoveComponent(NativeArray<Entity> entities, in ComponentTypeSet componentTypeSet)

Parameters

The NativeArray of entities to have components removed.

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, or if any of the component types are Entity or Prefab.

RemoveComponent(EntityQuery, ComponentType, EntityQueryCaptureMode)

Records a command to remove a component from all entities matching a query.
public void RemoveComponent(EntityQuery entityQuery, ComponentType componentType, EntityQueryCaptureMode queryCaptureMode)

Parameters

entityQuery

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

componentType

The types of component to remove.

queryCaptureMode

Controls when the entities matching
entityQuery
are computed and captured.

Remarks

Does not affect entities already missing the component.

RemoveComponent(EntityQuery, ComponentType)

Warning
Deprecated. 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

entityQuery

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

componentType

The type of component to add.

RemoveComponent<T>(EntityQuery, EntityQueryCaptureMode)

Records a command to remove a component from all entities matching a query.
public void RemoveComponent<T>(EntityQuery entityQuery, EntityQueryCaptureMode queryCaptureMode)

Parameters

entityQuery

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

queryCaptureMode

Controls when the entities matching
entityQuery
are computed and captured.

Remarks

Does not affect entities already missing the component.

RemoveComponent<T>(EntityQuery)

Warning
Deprecated. 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

entityQuery

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

RemoveComponent(EntityQuery, ComponentTypeSet, EntityQueryCaptureMode)

Records a command to remove multiple components from all entities matching a query.
public void RemoveComponent(EntityQuery entityQuery, in ComponentTypeSet componentTypeSet, EntityQueryCaptureMode queryCaptureMode)

Parameters

entityQuery

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

componentTypeSet

The types of components to remove.

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.)

RemoveComponent(EntityQuery, ComponentTypeSet)

Warning
Deprecated. 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

entityQuery

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

componentTypeSet

The types of components to remove.