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

EntityQueryBuilder

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

EntityQueryBuilder is unmanaged and compatible with the Burst compiler. It is the recommended way to create an EntityQuery, and can be used for both SystemBase and ISystem.

Use an EntityQueryBuilder object to describe complex queries.

A query description combines the component types you specify (using methods like WithAll, WithAny, and WithNone) sets according to the following rules:

" All - Includes archetypes that have every component in this set, but only includes entities where the component is enabled. " 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 components are 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.

Constructors

Constructor Description
EntityQueryBuilder Create an entity query description builder.

Public Methods

Method Description
AddAdditionalQuery Add an additional query description to a single EntityQuery.
Build Create an EntityQuery owned by an ISystem's SystemState.
Dispose Dispose the builder and release the memory.
Reset Reset the builder for reuse.
WithAbsent Add absent component types to the query.
WithAbsentChunkComponent Add an absent Chunk Component type to the query.
WithAll Add required component types to the query.
WithAllChunkComponent Add a read-only required chunk component type to the query.
WithAllChunkComponentRW Add a required chunk component type to the query.
WithAllRW Add required component types to the query with ReadWrite mode.
WithAny Add optional component types to the query.
WithAnyChunkComponent Add an optional read-only chunk component type to the query.
WithAnyChunkComponentRW Add an optional chunk component type to the query.
WithAnyRW Add optional component types to the query with ReadWrite mode.
WithDisabled Add required disabled component types to the query.
WithDisabledRW Add required disabled component types to the query with ReadWrite mode.
WithNone Add excluded component types to the query.
WithNoneChunkComponent Add an excluded Chunk Component type to the query.
WithOptions Set options for the current query.
WithPresent Add required component types to the query, whether the type is enabled or not.
WithPresentChunkComponent Add a required read-only chunk component type to the query, whether it is enabled or disabled.
WithPresentChunkComponentRW Add a required chunk component type to the query, whether it is enabled or disabled.
WithPresentRW Add required component types to the query with ReadWrite mode, whether they are enabled or disabled.