Search Unity

Difference between IJobForEachWithEntity nad and IJobForEach?

Discussion in 'Entity Component System' started by nek1113, Sep 3, 2019.

  1. nek1113

    nek1113

    Joined:
    Apr 10, 2019
    Posts:
    12
    what is the difference between the two?
     
  2. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    IJobForEachWithEntity includes parameters for entity and index in the Execute method. If you need entity access, or are using parallel or concurrent writers (i.e. EntityCommandBuffer.Concurrent) you should use that over IJobForEach.
     
    nek1113 likes this.
  3. nek1113

    nek1113

    Joined:
    Apr 10, 2019
    Posts:
    12
    so what do indexes show exactly?
     
  4. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
    nek1113 likes this.
  5. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,262
    The index parameter can also be used to index a NativeArray that is the size of EntityQuery.CalculateEntityCount(). The ordering is stable for all usages between two structural change sync points.
     
    nek1113 likes this.