Search Unity

Comparing every "Frog" and "Toad" with ECS (How to iterate over 2 different groups with pure ECS?)

Discussion in 'Entity Component System' started by Mr-Mechanical, Nov 17, 2018.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    Code (CSharp):
    1. for(int i = 0; i < toads.Length; i++) {
    2.       for(int i = 0; i < frogs.Length; i++) {
    3.              ImportantCalculation();
    4.       }
    5. }
    I'd like to iterate over 2 different groups in a parallelizable manner with ECS. What's the best manner of doing this?
     
  2. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Mr-Mechanical likes this.
  3. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    beautiful. thank you

    I compared my initial implementation with the sample and I realized I was just missing a [NativeDisableParallelForRestriction] : )