[Solved] unsuccessfully list in ComponentData

Hi. I’m creating a Cellular Automata grid.
How to store a list inside a ComponentData?

My generation will increasy the size of the grid randomly later on.
I tried to hold a list of this struct inside a ComponentData, but “i’m hitting a wall”.

namespace Game.Map.Data {
   public struct NodeData {
      public MapNodeType Type; // this is an enum
      public int X;
      public int Y;
   }
}

Please help?

https://docs.unity3d.com/Packages/com.unity.entities@0.1/manual/dynamic_buffers.html

1 Like

At first it solved my problem until i enable my second ComponentSystem.
When this system change another ComponentData, all the data set in DynamicBuffer disappear.
This buffer have a limitation per ComponentSystem or is it a glitch?

When i stop the ComponentSystem to change any field on any other componentData, the buffer stays in my entity, but if i change a field in any component i lose my buffer. I don’t know what to do.

I apologise. I solved my problem as i typed my systems in Post-it and placed them on the wall.
I realize that i was missing the System Update Order.

Yes, after any structural change, the original pointer to the buffer becomes invalid. You can either use a EntityCommandBuffer like you said or use GetBuffer to grab the DB again.