docs.unity.cn
    Show / Hide Table of Contents

    Method WithAbsentChunkComponent

    WithAbsentChunkComponent<T>()

    Add an absent Chunk Component type to the query.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData)})]
    public EntityQueryBuilder WithAbsentChunkComponent<T>()
    Returns
    Type Description
    EntityQueryBuilder

    The builder object that invoked this method.

    Type Parameters
    Name Description
    T

    Component type to use as an absent Chunk Component

    Remarks

    Call this method on the query builder to exclude any entities that have the specified chunk component. Chunk components are a distinct component type, which are different from excluding the same type as a standard component.

               var entityWithPlayerComponent = EntityManager.CreateEntity();
               EntityManager.AddComponent<Player>(entityWithPlayerComponent);
    
               var entityWithPlayerChunkComponent = EntityManager.CreateEntity();
               EntityManager.AddComponent(entityWithPlayerChunkComponent, ComponentType.ChunkComponent<Player>());
    
               // This query will only match entityWithPlayerChunkComponent, excluding entityWithPlayerComponent
               var noPlayerQuery = new EntityQueryBuilder(Allocator.Temp)
                   .WithNone<Player>()
                   .Build(this);
    
               // This query will only match entityWithPlayerComponent, excluding entityWithPlayerChunkComponent
               var noChunkPlayerQuery = new EntityQueryBuilder(Allocator.Temp)
                   .WithNoneChunkComponent<Player>()
                   .Build(this);

    To add additional excluded Chunk Components, call this method multiple times.

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

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