Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

EntityManager.Exists

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool Exists(Entity entity);

Parameters

Parameter Description
entity The Entity object to check.

Returns

bool True, if Entity.Version matches the version of the current entity at Entity.Index in the entities array.

Description

Reports whether an Entity object is still valid.

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.