Method DestroyEntity
DestroyEntity(Entity)
Records a command to destroy an entity.
Declaration
public void DestroyEntity(Entity e)
Parameters
| Type | Name | Description |
|---|---|---|
| Entity | e | The entity to destroy. |
Remarks
At playback, this command throws an error if the entity is deferred, or was destroyed between recording and playback, or if the entity has the Prefab tag.
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. |
DestroyEntity(NativeArray<Entity>)
Records a command to destroy a NativeArray of entities.
Declaration
public void DestroyEntity(NativeArray<Entity> entities)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArray<Entity> | entities | The NativeArray of entities to destroy. |
Remarks
At playback, this command only runs if the entity count is greater than 0. This command throws an error if any of the entities are deferred, were destroyed between recording and playback, or if any of the entities have the Prefab tag.
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. |
DestroyEntity(EntityQuery, EntityQueryCaptureMode)
Records a command to destroy all entities matching a query.
Declaration
public void DestroyEntity(EntityQuery entityQuery, EntityQueryCaptureMode queryCaptureMode)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityQuery | entityQuery | The query specifying the entities to destroy. |
| EntityQueryCaptureMode | queryCaptureMode | Controls when the entities matching |
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. |
DestroyEntity(EntityQuery)
Obsolete. Use DestroyEntity(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 DestroyEntity(EntityQuery entityQuery)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityQuery | entityQuery | The query specifying the entities to destroy. |