Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

MonoBehaviour & SystemBase execution order

Discussion in 'Entity Component System' started by Greenwar, Oct 15, 2020.

  1. Greenwar

    Greenwar

    Joined:
    Oct 11, 2014
    Posts:
    54
    Hey,

    I'm just getting back into ECS and haven't really kept up with the API changes for the past year or so.
    What are the best practices and/or calls needed to have a certain number of MonoBehaviours reliably execute before a group of systems?

    Do I just manually call them still, or are there any new standards?
     
  2. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    305
    Call them manually using a SystemBase class then align it using UpdateBefore, UpdateAfter, or UpdateInGroup headers.

    If you can, try to convert the monobehavior methods to a SystemBase class. In my experience, most cases can be easily converted by just changing Update() to OnUpdate(). A SystemBase doesnt even need to have any Entities or Jobs, it can easily just be pure mono elements.
     
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,217
    Default system ordering hasn't changed relative to the playerloop. MonoBehaviours still update before the SimulationSystemGroup updates. There's new API in ScriptBehaviourUpdateOrder that lets you position any system anywhere in the playerloop. Be careful though, as the playmode and build playerloops are different. So you can also update systems after LateUpdate or even after rendering.