Search Unity

Binding/Serializing a List of Lists

Discussion in 'UI Toolkit' started by inSight01, Jan 30, 2020.

  1. inSight01

    inSight01

    Joined:
    Apr 18, 2017
    Posts:
    17


    I'm not the best at explaining things and I'm a total noob at programming/UIElements so I made a simple picture which hopefully can convey what I want.

    So, I'm creating an editor whereby I can add groups. These groups will allow me to add items to that group. There is a button attached to these groups and items which allow me to remove them. An item can remove itself and a group can remove itself and all it's containing items.

    This is super easy to accomplish with UIElements as VisualElements can remove themselves, and all their children, from the hierarchy and you can access the parent that it's attached to which makes everything super easy to deal with such as changing the index position of child elements to move them up and down etc.

    However, I'm wanting to save this information and this is where I'm totally lost. I figured I could create a list of these groups and those groups can contain a list of items. But I can't figure out how to link it all up as lists aren't nearly as flexible. An Item doesn't know what Group it belongs to and it's not like I can call Item.RemoveFromList like I can VisualElement.RemoveFromHierarchy.
     
unityunity