Class EntityQueryDesc | Entities | 0.2.0-preview.18
docs.unity3d.com
    Show / Hide Table of Contents

    Class EntityQueryDesc

    Defines a queryDesc to find archetypes with specific components.

    Inheritance
    Object
    EntityQueryDesc
    Namespace: Unity.Entities
    Syntax
    public class EntityQueryDesc
    Remarks

    A queryDesc combines components in the 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

    For example, given entities with the following components:

    • Player has components: Position, Rotation, Player
    • Enemy1 has components: Position, Rotation, Melee
    • Enemy2 has components: Position, Rotation, Ranger

    The queryDesc below would give you all of the archetypes that: have any of [Melee or Ranger], AND have none of [Player], AND have all of [Position and Rotation]

    new EntityQueryDesc {
        Any = new ComponentType[] {typeof(Melee), typeof(Ranger)},
        None = new ComponentType[] {typeof(Player)},
        All = new ComponentType[] {typeof(Position), typeof(Rotation)}
    }

    In other words, the queryDesc selects the Enemy1 and Enemy2 entities, but not the Player entity.

    Fields

    All

    The queryDesc includes archetypes that contain all of the components in the All list.

    Declaration
    public ComponentType[] All
    Field Value
    Type Description
    ComponentType[]

    Any

    The queryDesc includes archetypes that contain at least one (but possibly more) of the components in the Any list.

    Declaration
    public ComponentType[] Any
    Field Value
    Type Description
    ComponentType[]

    None

    The queryDesc excludes archetypes that contain any of the components in the None list.

    Declaration
    public ComponentType[] None
    Field Value
    Type Description
    ComponentType[]

    Options

    Specialized queryDesc options.

    Declaration
    public EntityQueryOptions Options
    Field Value
    Type Description
    EntityQueryOptions
    Remarks

    You should not need to set these options for most queriesDesc.

    Options is a bit mask; use the bitwise OR operator to combine multiple options.

    Methods

    Validate()

    Declaration
    [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
    public void Validate()
    In This Article
    • Fields
      • All
      • Any
      • None
      • Options
    • Methods
      • Validate()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023