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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Feedback to unclear [UpdateAfter] and [UpdateInGroup] interaction

Discussion in 'Entity Component System' started by floAr, Jul 30, 2019.

  1. floAr

    floAr

    Joined:
    Oct 14, 2013
    Posts:
    5
    Hey there, I've been playing around with the current ECS preview and notivedsome unclear interactions.

    I have 3 systems (TurnBasedEngineSystem, PlayerActionSystem and BombSystem) as well as one group (ProgressGameStateGroup) with the following declarions:

    Code (CSharp):
    1. public class TurnBasedEngineSystem : JobComponentSystem {}
    2.  
    3. [UpdateAfter(typeof(TurnBasedEngineSystem))]
    4. public class ProgressGameStateGroup : ComponentSystemGroup { }
    5.  
    6. [UpdateInGroup(typeof(ProgressGameStateGroup))]
    7. public class PlayerActionSystem: ComponentSystem {}
    8.  
    9. [UpdateAfter(typeof(PlayerActionSystem))]
    10. public class BombSystem: JobComponentSystem {}
    My expectation would be that I have TurnBasedEngineSystem somewhere In my system loop within SimulationSystemGroup, followed by my ProgressGameStateGroup which contains the PlayerActionSystem and have the BombSystem update afterwards. (I'm unsure if would also expect it to be in the same group, as PlayerActionSystem, but beside this I expect it to run afterwards in any case).
    What I actually get is:
    upload_2019-7-30_10-43-16.png

    Adding the
    [UpdateInGroup(typeof(ProgressGameStateGroup))]
    to the BombSystem resolves this problem.

    Again my expectation would be to keep the BombSystem after the PlayerSystem in the full stack, or at least get some runtime warning about the two systems beeing in different groups and therefore not beeing able to update after each other.
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,635
    You should be getting a warning for this, sure you don't have them hidden?

    Code (CSharp):
    1. [UpdateAfter(typeof(PlayerActionSystem))]
    2. public class BombSystem: JobComponentSystem {}
    You can only updateafter/updatebefore systems in the same group. to get your code to work this should be

    Code (CSharp):
    1. [UpdateAfter(typeof(ProgressGameStateGroup))]
    2. public class BombSystem: JobComponentSystem {}
     
  3. floAr

    floAr

    Joined:
    Oct 14, 2013
    Posts:
    5
    *head -> table* You are right there is a warning, I take everything back :)