Question about [UpdateInGroup] [UpdateBefore] [UpdateAfter]

If I have 3 system named A B C and with using UnityEngine.Experimental.PlayerLoop;

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

Do B and C guarantee to be before the Update?

[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

  1. 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

1 Like
  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

2 Likes

Thank you so much!!

@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://discussions.unity.com/t/702113 . I was trying to do [UpdateBefore(typeof(Update))]

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.

2 Likes