Search Unity

Help Wanted Does it exist: EntityQuery.ToEntityKeyValuePairArray<T>()

Discussion in 'Data Oriented Technology Stack' started by metageist, Aug 31, 2021.

  1. metageist

    metageist

    Joined:
    Mar 16, 2019
    Posts:
    5
    We have access to EntityQuery.ToEntityArray()
    We also have access to EntityQuery.ToComponentDataArray<T>()
    Both of which access the same data set

    Would it be possible, then, to add a method EntityQuery.ToEntityKeyValuePairArray<T>() that would give a KeyValuePair array of the selected entities and a ComponentData of selected type <T> attached to it?

    This would be useful for my project in which a grid of Entities each have an attached Coordinates ComponentData assigned to it
    I could then iterate and work with each entity and its corresponding coordinates component all at once.

    Or is there already another way in ECS to more efficiently get such a packaged entity-component relationship?
     
  2. metageist

    metageist

    Joined:
    Mar 16, 2019
    Posts:
    5
    Ignore this thread; thinking too hard when all I needed was an Entities.ForEach((Entity en, Coordinates coords) => {...});
     
    Bonkurazu likes this.
unityunity