#Native Container IComponentData baking support

1 messages · Page 1 of 1 (latest)

sick pollen
#

From my testing, looks like pre.15 release still can't write authoring monobehavior to bake IComponentData that contains native containers like NativeList, NativeArray and etc. into subscene. Can official make it support in next or future release?

karmic magnet
sick pollen
karmic magnet
#

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

sick pollen
karmic magnet
#

just use Dynamic buffers then, it's by far the easiest solution with SystemAPI

sick pollen
karmic magnet
#

it's pretty much the same thing, just managed by entities system

#

and is tied to lifetime of entity in a chunk

sick pollen
# karmic magnet you share buffers

I need to share key and multiple values structure like NativeMultiHashMap. Simple Array/List structure like dynamic buffer is not enough for me.

karmic magnet
#

similiar to PhysicsWorld

acoustic hornet
#

there's always Unsafe* versions of the containers, but you'll have to manage their lifecycle agressively, preferably with an ICleanupComponent

warm heath
#

are DynamicBuffers any slower than UnsafeList?

karmic magnet
#

Except maybe if your dynamic buffer is stored in chunk

#

In which case it's faster

acoustic hornet
#

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.

warm heath
sick pollen