#Native Container IComponentData baking support
1 messages · Page 1 of 1 (latest)
Doubt this will be supported ever tbh. Use Dynamic buffers
I already use dynamic buffer and at the same time I also need to use native container IComponentData. Currently with this limitation, it makes things become complicated to setup and also introduce structural changes
that is only runtime
and it will be non-trivial to make it otherwise
since native collection is just a pointer to unmanaged heap
technically
NativeCollections are not even meant to be stored on ICD
that breaks safety system
I know. Just want to further simplify the code.
just use Dynamic buffers then, it's by far the easiest solution with SystemAPI
I believe it should be the correct way to use it. If not how u share native container easily across multiple systems?
you share buffers
it's pretty much the same thing, just managed by entities system
and is tied to lifetime of entity in a chunk
I need to share key and multiple values structure like NativeMultiHashMap. Simple Array/List structure like dynamic buffer is not enough for me.
then you should probably be fine making it in runtime
similiar to PhysicsWorld
there's always Unsafe* versions of the containers, but you'll have to manage their lifecycle agressively, preferably with an ICleanupComponent
are DynamicBuffers any slower than UnsafeList?
Same thing
Except maybe if your dynamic buffer is stored in chunk
In which case it's faster
if your DynamicBuffer would cause chunk fragmentation, you can set the capacity to 0 with the [InternalBufferCapacity] and it'll be stored outside the chunk.
If it's not too big, I'd just go with DynamicBuffer
if the data would be read-only and duplicated between instances, you should probably store it in a blob array.
If it's associated specifically with a system, you could make it either part of a SystemHandle entity, or a Singleton entity.
Alternatively, if you need more complex data structures only associated with a system and only that system writes to them, I'd put them as fields in a system and have them be readonly accessible outside the system via accessors so other systems can read/pass them to jobs.
If you really really need like a non-list native container per-entity, then Unsafe* containers might be an acceptable way to go assuming you're ensuring all lifecycle corner cases are handled correctly.
i`m using NativeList<T> and it works
@fleet ibex I would like to know whether official has any plan to support this feature. It will be really nice that I no longer need to write a init native collection IComponentData system at runtime when I can just bake it.