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.
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.
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.
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.
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
The query specifying the entities from which the component is removed.
The types of component to remove.
Controls when the entities matching are computed and captured.
entityQueryRemarks
Does not affect entities already missing the component.
RemoveComponent(EntityQuery, ComponentType)
Obsolete. Use EntityCommandBuffer.RemoveComponent instead.
public void RemoveComponent(EntityQuery entityQuery, ComponentType componentType)
Parameters
The query specifying the entities to which the component is added.
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
The query specifying the entities from which the component is removed.
Controls when the entities matching are computed and captured.
entityQueryRemarks
Does not affect entities already missing the component.
RemoveComponent<T>(EntityQuery)
Obsolete. Use EntityCommandBuffer.RemoveComponent instead.
public void RemoveComponent<T>(EntityQuery entityQuery)
Parameters
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
The query specifying the entities from which the components are removed.
The types of components to remove.
Controls when the entities matching are computed and captured.
entityQueryRemarks
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)
Obsolete. Use EntityCommandBuffer.RemoveComponent instead.
public void RemoveComponent(EntityQuery entityQuery, in ComponentTypeSet componentTypeSet)
Parameters
The query specifying the entities from which the components are removed.
The types of components to remove.