GetComponentDataArray cannot be called on zero-sized iComponentData

GetComponentDataArray<NoxEcs.CameraTarget> cannot be called on zero-sized IComponentData

I have tried adding the component in all the recommended ways,

EntityManager.AddComponent(entity, ComponentType.Create<CameraTarget>())

PostUpdateCommands.AddComponent<CameraTarget>(entity, new CameraTarget{});

EntityManager.AddComponent(entity, typeof(CameraTarget))

all give the same error

The component struct must contain fieds for you to be able to use GetComponentDataArray

1 Like

of course…thanks

Zero sized components don’t exist, because they have no data.

The archetype just has knowledge that the type is part of the chunk so can be used for filtering but there’s nothing in the chunk because again, they have no data. What would be stored? So if nothing exists there’s nothing to get.

As quote above those don’t really exist. Empty components are used as “Tags” and to know their existence of those zero sized components you can call

          // for getting the amount of components in the group
          ComponentGroup.CalculateLength();
          // for testing the existence for such component in an entity
          EntityManager.HasComponent(Entity, typeof(NoxEcs.CameraTarget));
          // for testing the existence of such component in a Chunk
          ArchetypeChunk.Has(ArchetypeChunkComponentType<NoxEcs.CameraTarget> chunkComponentType);

Try to access components with no data will cause exception like:

ArgumentException: ArchetypeChunk.GetNativeArray<> cannot be called on zero-sized IComponentData
ArgumentException: GetComponentDataArray<> cannot be called on zero-sized IComponentData