Do ECS systems run before or after GameObject Update?

Apologies if I’m missing something obvious. In relation to this order of execution:

  1. When do parallel jobs start running?
  2. By when do they all join?
  3. When do main thread Entities.ForEach lambdas run?

It looks like, the answer is:

  • Update runs
  • All the systems run and rejoin. Their order is documented here.
  • LateUpdate runs

This seems eminently reasonable, because it allows MonoBehaviors to send some information to the ECS world (I’m doing this with SetComponentData) and then LateUpdate allows MonoBehaviors to read ECS data and make last-minute changes to the scene before the draw loop.

The above appears to be true for 2020.1f, with entities 0.9.0. How settled is this design? Is the apparent behavior intended, and can we reasonably expect it to remain?

Nice job answering your own question! (I love when I do that). :smile:

To clarify on update order, though:
First -
Standard Initialization Occurs
Then -
InitializationSystemGroup OnUpdate Runs

First -
MONO Update Runs
Then -
SimulationSystemGroup OnUpdate Runs

First -
MONO LateUpdate Runs
Then -
PresentationSystemGroup OnUpdate Runs

This is obviously not as comprehensive and explicit as the official ECS Documentation (of which you found), and anyone wondering what the exact Update Order of the major ECS SystemGroups should definitely refer to that link (rather than my primitive clarification). But I felt like I should quickly make a minor correction, just in case anyone who stumbles by this thread doesn’t read the official ECS Documentation link in your post. :stuck_out_tongue:

4 Likes

You can also do some custom hooks into the game loop, although you shouldn’t need to most of the time (unless using UnityRx)