docs.unity.cn
    Show / Hide Table of Contents

    Method WithAny

    WithAny<T1>()

    Add optional component types to the query.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData)})]
    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
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData)})]
    public EntityQueryBuilder WithAny<T1, T2>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1
    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
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData)})]
    public EntityQueryBuilder WithAny<T1, T2, T3>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1
    T2
    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
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData)})]
    public EntityQueryBuilder WithAny<T1, T2, T3, T4>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1
    T2
    T3
    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
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData)})]
    public EntityQueryBuilder WithAny<T1, T2, T3, T4, T5>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T1
    T2
    T3
    T4
    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
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData)})]
    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
    T2
    T3
    T4
    T5
    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
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData), typeof(BurstCompatibleComponentData)})]
    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
    T2
    T3
    T4
    T5
    T6
    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
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(FixedList32Bytes<ComponentType>)})]
    public EntityQueryBuilder WithAny<T>(ref T componentTypes)
        where T : INativeList<ComponentType>
    Parameters
    Type Name Description
    T componentTypes

    A list of component types that implements INativeList<T>. For example, NativeList<T> or 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>()

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023