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

EntityQueryDesc

class in Unity.Entities

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

Description

Describes a query to find archetypes in terms of required, optional, and excluded components.

Define an EntityQueryDesc object to describe complex queries. Inside a system, pass an EntityQueryDesc object to ComponentSystemBase.GetEntityQuery 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]



In other words, the query created from this description selects the Enemy1 and Enemy2 entities, but not the Player entity.

Properties

Property 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.

Public Methods

Method Description
Equals Compare to another object 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

Operator Description
operator != Compare two instance for inequality.
operator == Compare two instance for equality.