Struct TraitQuery | Semantic Traits | 0.2.8-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Struct TraitQuery

    Query object

    Namespace: Unity.Semantic.Traits.Queries
    Syntax
    public struct TraitQuery : IEnumerable<Entity>, IEnumerable, IDisposable

    Constructors

    TraitQuery(EntityManager)

    Create a new TraitQuery, which caches results, and must be disposed after its use

    Declaration
    public TraitQuery(EntityManager entityManager)
    Parameters
    Type Name Description
    EntityManager entityManager

    The entity manager that will be used for entity queries

    Properties

    EntityCount

    Count of entities resulting from the trait query

    Declaration
    public int EntityCount { get; }
    Property Value
    Type Description
    Int32

    Item[Int32]

    Access the element at the specified index from the trait query results

    Declaration
    public Entity this[int index] { get; }
    Parameters
    Type Name Description
    Int32 index

    Index of the element from the results

    Property Value
    Type Description
    Entity

    Methods

    Clone()

    Clone an existing trait query (in order to preserve the original)

    Declaration
    public TraitQuery Clone()
    Returns
    Type Description
    TraitQuery

    A copy of this trait query with a new cache for query results (that must be disposed)

    Dispose()

    Declaration
    public void Dispose()

    GetEnumerator()

    Return the query result or perform the query if not completed

    Declaration
    public IEnumerator<Entity> GetEnumerator()
    Returns
    Type Description
    IEnumerator<Entity>

    Query result

    Or()

    Add a new conditional group to the query with an OR operator

    Declaration
    public TraitQuery Or()
    Returns
    Type Description
    TraitQuery

    An updated trait query with a new conditional group

    Reset()

    Reset the current cached results of the query, so that it can be re-executed

    Declaration
    public void Reset()

    WithFilter<T>(T)

    Constrain the trait query further with a filter (use Clone() to preserve original)

    Declaration
    public TraitQuery WithFilter<T>(T filter)
        where T : IQueryFilter
    Parameters
    Type Name Description
    T filter

    Filter to add to the trait query

    Returns
    Type Description
    TraitQuery

    An updated trait query w/ the filter

    Type Parameters
    Name Description
    T

    A filter type that implements IQueryFilter

    Extension Methods

    ConditionTypesExtension.Where<T>(TraitQuery, T, ConditionFilter<T>.ValidComparer)
    ConditionTypesExtension.Where<T>(TraitQuery, ConditionFilter<T>.ValidComparer)
    WithoutTraitTypesFilterExtension.WithoutTraitTypes<T>(TraitQuery)
    WithoutTraitTypesFilterExtension.WithoutTraitTypes<T1, T2>(TraitQuery)
    WithoutTraitTypesFilterExtension.WithoutTraitTypes<T1, T2, T3>(TraitQuery)
    WithoutTraitTypesFilterExtension.WithoutTraitTypes(TraitQuery, ComponentType[])
    WithTraitTypesExtension.WithTraitTypes<T>(TraitQuery)
    WithTraitTypesExtension.WithTraitTypes<T1, T2>(TraitQuery)
    WithTraitTypesExtension.WithTraitTypes<T1, T2, T3>(TraitQuery)
    WithTraitTypesExtension.WithTraitTypes(TraitQuery, ComponentType[])
    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