Exists(Entity)
Reports whether an Entity object is still valid.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
public bool Exists(Entity entity)
Parameters
The Entity object to check.
Returns
Type | Description |
|---|---|
| bool | True, if Entity.Version matches the version of the current entity at Entity.Index in the entities array. |
Remarks
An Entity object does not contain a reference to its entity. Instead, the Entity struct contains an index and a generational version number. When an entity is destroyed, the EntityManager increments the version of the entity within the internal array of entities. The index of a destroyed entity is recycled when a new entity is created.
After an entity is destroyed, any existing Entity objects will still contain the older version number. This function compares the version numbers of the specified Entity object and the current version of the entity recorded in the entities array. If the versions are different, the Entity object no longer refers to an existing entity and cannot be used.