Hello, I have a very straightforward system:
public partial struct MySystem : ISystem
{
private EntityQuery _activePlayersQuery;
public void OnCreate(ref SystemState state)
{
_activePlayersQuery = SystemAPI.QueryBuilder().WithAll<ActivePlayerTag, Transform>().Build();
state.RequireForUpdate(_activePlayersQuery);
}
public void OnUpdate(ref SystemState state)
{
var activePlayerPosition = _activePlayersQuery.GetSingleton<Transform>().position;
...
}
}
Where ActivePlayerTag is an empty IComponentData and Transform is the UnityEngine transform.
I’ve been reported a weird case in a build run where the GetSingleton() method generated this error:
Exception: InvalidOperationException: GetSingleton() failed: found no chunk that matches the provided filter.
Unity.Entities.EntityQueryImpl.GetSingletonChunk (Unity.Entities.TypeIndex typeIndex, System.Int32& outIndexInArchetype, Unity.Entities.Chunk*& outChunk) (at <00000000000000000000000000000000>:0)
Unity.Entities.EntityQueryManagedComponentExtensions.GetSingleton[T] (Unity.Entities.EntityQuery query) (at <00000000000000000000000000000000>:0)
Any Idea on what’s going on?