Search Unity

[Solved] unsuccessfully list in ComponentData

Discussion in 'Entity Component System' started by PJRM, Nov 2, 2019.

  1. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    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".
    Code (CSharp):
    1. namespace Game.Map.Data {
    2.    public struct NodeData {
    3.       public MapNodeType Type; // this is an enum
    4.       public int X;
    5.       public int Y;
    6.    }
    7. }
    Please help?
     
  2. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
  3. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    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.
     
  4. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    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.
     
  5. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
    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.