Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

How to ensure that a system is the first system to run among other systems?

Discussion in 'Data Oriented Technology Stack' started by davenirline, Dec 7, 2018.

  1. davenirline


    Jul 7, 2010
    I'm making a system that collects commands in an EntityCommandBuffer outside of ECS context (MonoBehaviours). When the systems updates executes, I want a system to playback the collected commands as a starting system. This way, the subsequent systems can filter the newly applied components and entities.

    The current way to do this is to add [UpdateAfter] in every system that I made. This is not maintenance friendly. I would eventually go this route if there's no other way. So is there a way to make a system run first?
    Last edited: Dec 7, 2018
  2. eizenhorn


    Oct 17, 2016
    You can group systems by UpdateInGroup and set UpdateBefore this group for your "first" system. But yes attribute chains it's only way.
  3. 5argon


    Jun 10, 2013
    You may exploit the default that all systems are placed in the Update step, so put your playback system in Initialization step. It works as long as you avoid using Initialization step. *Currently in my game EndFrameBarrier is down below the Update step even though it has Initialization step attribute, not sure what is going on. From the code comment :

    Code (CSharp):
    1.     [UpdateBefore(typeof(Initialization))]
    2.     [Preserve]
    3.     public class EndFrameBarrier : BarrierSystem
    4.     {
    5.     }