seems like you want a IBufferElementData instead:
public struct SpawnPrefabData : IBufferElementData
{
public Entity Prefab;
public float Foo; // couldn't read the name, but seemed to be related to the Prefab array
}
Then access it as a DynamicBuffer
Hey, I’m attempting to do something similar. Really, I’m just trying to keep track of bones in the easiest method possible. I’m kind of terrible at Unity, but this is a goal I’m trying to meet. But I think my goal is the same, store an array of entities in a component.
So, during baking, I’m iterating through all the children transforms and add them to a list. I want to have a component that keeps them all in a list. I wouldn’t mind some type of dictionary, but I could get away with just an array and rely on the index.
Now, I see a lot of articles about dynamic buffers, but I don’t need something to be resized and really once its set, it’s never going to change. Could someone provide me some advice on how to best approach this? I assume the ideal choice would come out of Unity.Collections like a NativeArray, but I’m having trouble imagining it enough to understand it.
I was trying to keep my life simple by chaining systems to ultimately lead to scheduling moving and rotating each bone to match animations, and in my loop, I’m trying to give each “rig” its data when its scheduled, and it’s important to how I’m keeping the data organized.
Anyway, a list or array that stores references to each LocalToWorld, in a guaranteed order, even if I manually have to write reference in place of the array, would be awesome. If I can get away with storing a number and using some EntityManager method to fetch it fast, sounds neat. I’m kinda curious to learn what is really the “optimal” way of handling a situation like this.
The best option is still going to be DynamicBuffer. That’s what I do for “exposed skeletons” in Kinemation. Each element is an entity reference, and from that I can fetch whatever transform data I need, or query specific bones directly via normal ECS practices. ComponentLookup is a useful tool for looking up transform data on individual bone entities inside a job if that helps.
Note that this approach will not scale super well to thousands of animated characters. Part of that is that the built-in Entities Graphics has some issues when it comes to skinned meshes. And part of it is that the transform system will choke having to update all those bone hierarchies. The latter can be fixed by storing the bone transforms directly in a DynamicBuffer and using a blob asset to encode hierarchy relationships. This is what I do for “optimized skeletons” in Kinemation. The reason it is fast is that all the transforms in the hierarchy are linear in memory, so it is way more cache-efficient. Plus depending on your animation clip storage and sampling algorithms, your algorithm may benefit sampling the full pose at once. That’s definitely the case with Kinemation.


