Search Unity

  1. Full schedule for #UniteBerlin is now available! Featuring talks on our roadmap, hands-on labs and much more! Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Question about [UpdateInGroup] [UpdateBefore] [UpdateAfter]

Discussion in 'Entity Component System and C# Job system' started by 5argon, May 17, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    189
    If I have 3 system named A B C and with `using UnityEngine.Experimental.PlayerLoop;`

    1.

    [UpdateBefore(typeof(Update))]A
    [UpdateAfter(typeof(A))] B
    [UpdateAfter(typeof(B))] C

    Do B and C guarantee to be before the Update?

    2.

    [UpdateInGroup(typeof(MyGroup))] A
    [UpdateInGroup(typeof(MyGroup))] B
    [UpdateInGroup(typeof(MyGroup))] C

    Can I make the whole group updates before the Update? I tried putting [UpdateBefore(typeof(Update))] on the group class but it throws error. The only way is to add [UpdateBefore(typeof(Update))] to everything. There is nothing in any sample code that shows how to use UpdateInGroup other than this

    3. What does `PreLateUpdate` and `PostLateUpdate` and `EarlyUpdate` means when use with UpdateBefore/After? When game object only have "LateUpdate" and "Update"

    [UpdateAfter(typeof(PreLateUpdate))] - Am I updating BEFORE LateUpdate?
    [UpdateAfter(typeof(PostLateUpdate))] and [UpdateBefore(typeof(PostLateUpdate))] - Am I updating AFTER LateUpdate in both case?

    etc. the same questions for `EarlyUpdate`
     
    Last edited: May 17, 2018
    Creepgin likes this.
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    34
    1. no, there is not guarantee B and C will update before Update, just that they update after A.

    2. It should work, what error are you getting when adding UpdateBefore to the group class? The group needs to be plain class, not a system btw.

    3. UpdateBefore any update phase (like Update, EarlyUpdate etc) means update in that phase but before everything else inside the group. UpdateAfter means inside the group but after everything else in the phase. So yes, UpdateAfter PreLateUpdate means it will update before LateUpdate
     
    Creepgin and 5argon like this.
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    189
    Thank you so much!!
     
  4. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    189
    @timjohansson Sorry I tried using a group in every way possible (on a plain class) but the error still came up.
    The error I am getting when putting a group is the same as this person @jooleanlogic in this thread : https://forum.unity.com/threads/updateingroup-exception.532124/ . I was trying to do [UpdateBefore(typeof(Update))]
     
  5. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    34
    Based on the callstack it looks like a bug we fixed recently, the fix should be out in the next version of the ECS package.
     
    5argon likes this.