Do enable states work with Chunk components?

The 1.0 Experimental release notes state that the new enable states only work with IComponentData and IBufferElementData.

Chunk components use IComponentData. Will enable states work with chunk components?

Thanks for any explanation.

Bumping this. If anyone has information one way or another, it would be very helpful over here.

Looking at the 1.0 source code, I am skeptical it would be possible. ArchetypeChunk.SetComponentEnabled() takes an int for the entity’s index in the chunk. Chunk components are stored on the chunk’s meta chunk entity.

I don’t know if the meta chunk entity has an index in the chunk like normal entities do. I doubt it. Every time the source code needs that meta chunk entity, it just grabs it directly via a pointer.

Another mark against this: Unity stores the enable states in a 128 bit mask, and the 1.0 now lists the max chunk capacity as 128 entities…leaving no room for that chunk component in the mask.

[UPDATE] I’m not sure how, but this does seem to work. I was able to do a simple test. This works as expected (prints “true”):

Entity entity = state.EntityManager.CreateEntity();
ComponentType fooChunkComponentType = ComponentType.ChunkComponent<FooChunkComponent>();

state.EntityManager.AddChunkComponentData<FooChunkComponent>(entity);
state.EntityManager.SetComponentEnabled(entity, fooChunkComponentType, true);
bool isEnabled = state.EntityManager.IsComponentEnabled(entity, fooChunkComponentType);

Debug.Log(isEnabled);

So the chunk component does seem to be being disabled. I imagine if you wanted to do this using an ArchetypeChunk, you could call:

ArchetypeChunk.SetComponentEnabled<FooChunkComponent>(typeHandle, 0, false);

(though I have not tested that).

I’m not sure why this works. I must not understand where chunk components are stored. It seems like there wouldn’t be room for them in the v128 used to store enable bits for each chunk.

1 Like