Search Unity

Sync Point between System.

Discussion in 'Entity Component System' started by RoughSpaghetti3211, Sep 20, 2020.

  1. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    What is the best way to ensure system execution order and sync points? Currently, im using
    [UpdateBefore(typeof())] but it's hard to manage and I need to set some sync point between systems

    For example, I have a hex tile board with each tile as an entity. During run time the board can be wiped and regenerated but I need to have a sync point ensuring all the system that generates the board are complete before the rest of the simulate system run.

    Any insight into how people have been dealing with this would be greatly appreciated
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,270
    The alternative to attributes is explicit system ordering, in which you manually list out the order of systems to update. This typically requires a custom ComponentSystemGroup subclass to get right. I prefer this, so I wrote a very elaborate mechanism for setting it up.
     
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    [AlwaysSynchronizeSystem]
    ? (if it needed every frame)
     
  4. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Ok so if I don’t want to write a custom solution I will need to stick with UpdateBefore and after attribute?

    as for the [AlwaysSynchronizeSystem] is the idea to create a barrier system with this attribute and run all my generate tiles before and sim systems after ?
     
  5. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    One more thing you can do [UpdateInGroup(typeof(SimulationSystemGroup), OrderFirst = true, OrderLast = true)]
    Not explicit ordering but put them ahead or behind. Like those End/Start***CommmandBufferSystem

    Also, you can Define your own system group and put your system in that group.
    that will make sure that they are updated right after eachother. No other system will ever Jump into the queue.
    Code (CSharp):
    1.     [UpdateInGroup(typeof(SimulationSystemGroup)),UpdateAfter(typeof(TransformSystemGroup))]
    2.     public class MySystemGroup:ComponentSystemGroup{};
    3.  
    4.     [UpdateInGroup(typeof(MySystemGroup))]
    5.     public class MySystem:SystemBase{};
    As for the systems in your group will only be your own system. ordering them would be much easier
     
    Last edited: Sep 21, 2020
    RoughSpaghetti3211 likes this.
  6. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Ah yea , I’ll give this a try Thank you