docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method WithAny

    WithAny<T1>()

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T1>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1

    An optional component type

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    WithAny accepts up to seven type arguments. You can add more component types by chaining calls together.

    In the following example, an Entity must have either an ObjectUniformScale, ObjectNonUniformScale, and/or ObjectCompositeScale component in order to match the query:

    var query = new EntityQueryBuilder(Allocator.Temp)
        .WithAll<ObjectPosition>()
        .WithAny<ObjectUniformScale, ObjectNonUniformScale>()
        .WithAny<ObjectCompositeScale>()
        .Build(this);

    To add component types that are not known at compile time, use WithAny<T>(ref T)

    The query will request read-only access to the referenced component(s). To request read/write access, use Unity.Entities.EntityQueryBuilder.WithAnyRW``1(``0@)

    WithAny<T1, T2>()

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T1, T2>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1

    An optional component type

    T2

    An optional component type

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    WithAny accepts up to seven type arguments. You can add more component types by chaining calls together.

    In the following example, an Entity must have either an ObjectUniformScale, ObjectNonUniformScale, and/or ObjectCompositeScale component in order to match the query:

    var query = new EntityQueryBuilder(Allocator.Temp)
    .WithAll<ObjectPosition>()
    .WithAny<ObjectUniformScale, ObjectNonUniformScale>()
    .WithAny<ObjectCompositeScale>()
    .Build(this);

    To add component types that are not known at compile time, use WithAny<T>(ref T)

    The query will request read-only access to the referenced component(s). To request read/write access, use Unity.Entities.EntityQueryBuilder.WithAnyRW``1(``0@)

    WithAny<T1, T2, T3>()

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T1, T2, T3>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1

    An optional component type

    T2

    An optional component type

    T3

    An optional component type

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    WithAny accepts up to seven type arguments. You can add more component types by chaining calls together.

    In the following example, an Entity must have either an ObjectUniformScale, ObjectNonUniformScale, and/or ObjectCompositeScale component in order to match the query:

    var query = new EntityQueryBuilder(Allocator.Temp)
    .WithAll<ObjectPosition>()
    .WithAny<ObjectUniformScale, ObjectNonUniformScale>()
    .WithAny<ObjectCompositeScale>()
    .Build(this);

    To add component types that are not known at compile time, use WithAny<T>(ref T)

    The query will request read-only access to the referenced component(s). To request read/write access, use Unity.Entities.EntityQueryBuilder.WithAnyRW``1(``0@)

    WithAny<T1, T2, T3, T4>()

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T1, T2, T3, T4>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1

    An optional component type

    T2

    An optional component type

    T3

    An optional component type

    T4

    An optional component type

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    WithAny accepts up to seven type arguments. You can add more component types by chaining calls together.

    In the following example, an Entity must have either an ObjectUniformScale, ObjectNonUniformScale, and/or ObjectCompositeScale component in order to match the query:

    var query = new EntityQueryBuilder(Allocator.Temp)
    .WithAll<ObjectPosition>()
    .WithAny<ObjectUniformScale, ObjectNonUniformScale>()
    .WithAny<ObjectCompositeScale>()
    .Build(this);

    To add component types that are not known at compile time, use WithAny<T>(ref T)

    The query will request read-only access to the referenced component(s). To request read/write access, use Unity.Entities.EntityQueryBuilder.WithAnyRW``1(``0@)

    WithAny<T1, T2, T3, T4, T5>()

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T1, T2, T3, T4, T5>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1

    An optional component type

    T2

    An optional component type

    T3

    An optional component type

    T4

    An optional component type

    T5

    An optional component type

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    WithAny accepts up to seven type arguments. You can add more component types by chaining calls together.

    In the following example, an Entity must have either an ObjectUniformScale, ObjectNonUniformScale, and/or ObjectCompositeScale component in order to match the query:

    var query = new EntityQueryBuilder(Allocator.Temp)
    .WithAll<ObjectPosition>()
    .WithAny<ObjectUniformScale, ObjectNonUniformScale>()
    .WithAny<ObjectCompositeScale>()
    .Build(this);

    To add component types that are not known at compile time, use WithAny<T>(ref T)

    The query will request read-only access to the referenced component(s). To request read/write access, use Unity.Entities.EntityQueryBuilder.WithAnyRW``1(``0@)

    WithAny<T1, T2, T3, T4, T5, T6>()

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T1, T2, T3, T4, T5, T6>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1

    An optional component type

    T2

    An optional component type

    T3

    An optional component type

    T4

    An optional component type

    T5

    An optional component type

    T6

    An optional component type

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    WithAny accepts up to seven type arguments. You can add more component types by chaining calls together.

    In the following example, an Entity must have either an ObjectUniformScale, ObjectNonUniformScale, and/or ObjectCompositeScale component in order to match the query:

    var query = new EntityQueryBuilder(Allocator.Temp)
    .WithAll<ObjectPosition>()
    .WithAny<ObjectUniformScale, ObjectNonUniformScale>()
    .WithAny<ObjectCompositeScale>()
    .Build(this);

    To add component types that are not known at compile time, use WithAny<T>(ref T)

    The query will request read-only access to the referenced component(s). To request read/write access, use Unity.Entities.EntityQueryBuilder.WithAnyRW``1(``0@)

    WithAny<T1, T2, T3, T4, T5, T6, T7>()

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T1, T2, T3, T4, T5, T6, T7>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1

    An optional component type

    T2

    An optional component type

    T3

    An optional component type

    T4

    An optional component type

    T5

    An optional component type

    T6

    An optional component type

    T7

    An optional component type

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    WithAny accepts up to seven type arguments. You can add more component types by chaining calls together.

    In the following example, an Entity must have either an ObjectUniformScale, ObjectNonUniformScale, and/or ObjectCompositeScale component in order to match the query:

    var query = new EntityQueryBuilder(Allocator.Temp)
    .WithAll<ObjectPosition>()
    .WithAny<ObjectUniformScale, ObjectNonUniformScale>()
    .WithAny<ObjectCompositeScale>()
    .Build(this);

    To add component types that are not known at compile time, use WithAny<T>(ref T)

    The query will request read-only access to the referenced component(s). To request read/write access, use Unity.Entities.EntityQueryBuilder.WithAnyRW``1(``0@)

    WithAny<T>(ref T)

    Add optional component types to the query.

    Declaration
    public EntityQueryBuilder WithAny<T>(ref T componentTypes) where T : INativeList<ComponentType>
    Parameters
    Type Name Description
    T componentTypes

    A list of component types that implements Unity.Collections.INativeList<T>. For example, Unity.Collections.NativeList<T> or Unity.Collections.FixedList64Bytes<T>

    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T

    A container of component types

    Remarks

    To match the resulting query, an Entity must have at least one of the query's optional component types.

    To add component types that are known at compile time, use WithAny<T1>()

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)