#EntityManager.CreateEntityQuery() "managed array ComponentType[] not supported"

1 messages · Page 1 of 1 (latest)

shy saffron
#

Hello! I'm new to ECS and trying to query for a Singleton entity in a system's OnUpdate(ref SystemState state). For some reason, EntityManager.CreateEntityQuery() has an error "Creating a managed array Unity.Entities.ComponentType[] is not supported" despite having the annotation [ExcludeFromBurstCompatTesting("Takes managed array")].
My OnUpdate():

[BurstCompile]
public void OnUpdate(ref SystemState state)
{
    var board = SystemAPI.GetSingleton<Board>();
    var manager = state.EntityManager;
    // Error below
    EntityQuery query = manager.CreateEntityQuery(typeof(Board));
    query.TryGetSingletonEntity<Board>(out Entity boardEntity);
}

I have also tried replacing the typeof(Board) with ComponentType.ReadWrite<Board>(), same result.

zenith axle
#

can't use typeof either

shy saffron
#

Got it. I guess I have to define EntityQuerys in the OnCreate() or somewhere where not having Burst compilation is fine. Thank you!

zenith axle
#

SystemAPI.GetSingletonEntity<>() seems like what you want anyway?

shy saffron
#

That would work, I need the actual Singleton Board component from the entity as well so went this roundabout method. Probably would have been better to do a GetSingletonEntity<>() call and then get the component.

zenith axle
#

but if you really need the query then:

var query = SystemAPI.QueryBuilder().WithAll<Board>().Build();