Class EntityQueryDesc
Describes a query to find archetypes in terms of required, optional, and excluded components.
Namespace: Unity.Entities
Assembly: Unity.Entities.dll
Syntax
public class EntityQueryDesc
Remarks
Define an EntityQueryDesc object to describe complex queries. Inside a system, pass an EntityQueryDesc object to GetEntityQuery(params EntityQueryDesc[]) to create the EntityQuery.
A query description combines the component types you specify in All
, Any
, and None
sets according to the
following rules:
- All - Includes archetypes that have every component in this set
- Any - Includes archetypes that have at least one component in this set
- None - Excludes archetypes that have any component in this set, but includes entities which have the component disabled.
- Disabled - Includes archetypes that have every component in this set, but only matches entities where the component is disabled.
- Absent - Excludes archetypes that have any component in this set.
- Present - Includes archetypes that have every component in this set, whether or not the component is enabled.
For example, given entities with the following components:
- Player has components: ObjectPosition, ObjectRotation, Player
- Enemy1 has components: ObjectPosition, ObjectRotation, Melee
- Enemy2 has components: ObjectPosition, ObjectRotation, Ranger
The query description below matches all of the archetypes that: have any of [Melee or Ranger], AND have none of [Player], AND have all of [ObjectPosition and ObjectRotation]
EntityQueryDesc description = new EntityQueryDesc
{
Any = new ComponentType[] { typeof(Melee), typeof(Ranger) },
None = new ComponentType[] { typeof(Player) },
All = new ComponentType[] { typeof(ObjectPosition), typeof(ObjectRotation) }
};
In other words, the query created from this description selects the Enemy1 and Enemy2 entities, but not the Player entity.
Fields
Name | Description |
---|---|
Absent | Exclude archetypes that contain these component types. |
All | Include archetypes that contain all of the component types in the All list. |
Any | Include archetypes that contain at least one (but possibly more) of the component types in the Any list. |
Disabled | Include archetypes that contain these components, but only match entities where the component is disabled. |
None | Include archetypes that do not contain these component types. For enableable component types, archetypes with these components will still be matched by the query, but only for entities with these components disabled. |
Options | Specialized query options. |
Present | Include archetypes that contain these component types, whether or not the component is enabled. |
Methods
Name | Description |
---|---|
Equals(object) | Compare to another object for equality. |
Equals(EntityQueryDesc) | Compare to another instance for equality. |
GetHashCode() | Compute the hash code for this object |
Validate() | Run consistency checks on a query description, and throw an exception if validation fails. |
Operators
Name | Description |
---|---|
operator ==(EntityQueryDesc, EntityQueryDesc) | Compare two instance for equality. |
operator !=(EntityQueryDesc, EntityQueryDesc) | Compare two instance for inequality. |