Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. 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:
    589
    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:
    56
    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:
    589
    Thank you so much!!
     
  4. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    589
    @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:
    56
    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.