Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Maps in ComponentData

Discussion in 'Project Tiny' started by sp_steffenhees, May 9, 2019.

  1. sp_steffenhees

    sp_steffenhees

    Joined:
    May 2, 2019
    Posts:
    3
    Is it possible to store Maps (simple Objects) in the Components?
    It's possible to store arrays (e.g. array of EntityReferences), but is there a way to also create key value maps?
     
  2. Rupture13

    Rupture13

    Joined:
    Apr 12, 2016
    Posts:
    131
    There is no Map implementation present in Tiny.
    You could make your own implementation.

    For example, you could make an implementation where you first define a Tiny Struct with two fields (1 integer field for the key and 1 field with the desired fieldType for the value).
    You can then use an array of these created structs to make a map.

    Note: this example-implementation has some limits:
    1. EntityReferences don't work properly in structs, more about that here.
    2. Keys in this implementation are just integers and therefore don't enforce any uniqueness for the map.
     
    raymondyunity and Zionisias like this.