Search Unity

Question about [UpdateInGroup] [UpdateBefore] [UpdateAfter]

Discussion in 'Entity Component System' started by 5argon, May 17, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    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
    Singtaa likes this.
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    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
     
    Singtaa and 5argon like this.
  3. 5argon

    5argon

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

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    @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:
    473
    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.
     
    starikcetin and 5argon like this.