The type 'Transform' must be a non-nullable value type in order to use it as parameter 'T'

I am trying to grab the Transform component of an entity to put it into a Native Array so it can be used in a .ForEach().

OnCreate()

m_CameraEntityQuery = EntityManager.CreateEntityQuery(ComponentType.ReadOnly(), ComponentType.ReadOnly());

OnUpdate()

var level = m_CameraEntityQuery.ToComponentDataArrayAsync(Allocator.TempJob, out poseDep);

This causes an error:
The type 'Transform' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'EntityQuery.ToComponentDataArrayAsync<T>(Allocator, out JobHandle)'

How am I supposed to grab the Transform component data of an entity into a NativeArray?

You can’t since NativeArray only supports structs. You can use TransformAccessArray instead and use IJobParallelForTransform job.

1 Like

Thank you!