Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to pass a custom query to Entities.ForEach

Discussion in 'Entity Component System' started by aganm, Nov 5, 2020.

  1. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    I'm using EntityQuery to build different types of queries dynamically.

    I want to be able to do something like that

    EntityQuery myquery = GetEntityQuery(...);
    Entities.Query(myquery).ForEach(...)


    I was using queries with IJobForeach, but IJobForeach being removed, I need to be able to pass my queries to Entities.ForEach. I prefer not to use IJobChunk because of all the boilerplate it adds to my code.
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    you can't

    you'll probably need to wait for IJobEntity which should come at the same time IJobForEach gets removed
     
    charleshendry likes this.
  3. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    Oh thank you, I didn't know there was going to be an equivalent replacement.
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
  5. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    943
    Why not use IJobChunk instead?
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
     
    DreamingImLatios likes this.
  7. DaxodeUnity

    DaxodeUnity

    Unity Technologies

    Joined:
    Aug 5, 2021
    Posts:
    27
  8. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    bb8_1 likes this.