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

How to use ScheduleParallel with ForEach and JobComponentSystem?

Discussion in 'Entity Component System' started by Mr-Mechanical, Mar 30, 2020.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    Normally I would put a JobHandle inputDependencies into the schedule function however ScheduleParallel expects "EntityQuery". What should I do to use this ScheduleParallel?
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    Use SystemBase instead of JobComponentSystem.
     
    Mr-Mechanical likes this.
  3. TitoMakani

    TitoMakani

    Joined:
    Jan 20, 2020
    Posts:
    6
    Take a look at the dependency section of the Entities Documentation. Essentially the new SystemBase takes care of the implicit dependencies of any jobs that you schedule. You are able to overload this by passing in a JobHandle to the ScheduleParallel function, but then you have to make sure to update the system dependency with your final JobHandle.

    As for the EntityQuery, if you pass it in then it will just filter which entities are selected for the job, based on the query, like the old job structure.
     
    Mr-Mechanical likes this.