How to update system after SimulationSystemGroup (including EndSimulationEntityCommandBufferSystem)?

Is there a way to do so without writing custom bootstrap?
I’ve tried using UpdateAfter, but it doesn’t work unfortunately.

I want a system that runs after EndSimulationEntityCommandBufferSystem, since that system rans monobehaviours update. OrderLast on the EndSimulationECBSystem seems to be always puting it last in the group no matter what other systems attributes have.

Also, it has to be before PresentationSystemGroup / PreLateUpdate, because that would be too late, and that causes 1 frame rendering desync.

1 Like

If it can be at the very beginning of the PresentationSystemGroup (right after the BeginPresentationEntityCommandBufferSystem), yes, you can with
[UpdateInGroup(typeof(PresentationSystemGroup), OrderFirst = true)]. If not, then you will need a custom bootstrap.

1 Like

That causes 1 frame miss, unfortunately. Okay, I guess custom bootstrap is the way to go.

Soo, I’ve tried using custom bootstrap, and it doesn’t seems to help.
If I don’t add my component system group (AfterSimulationGroup) to the SimulationSystemGroup while rest of the systems are added, then manually add it - it still added before EndSimulationEntityCommandBufferSystem;

If I add AfterSimulationGroup after all systems, but before sort, its still added before EndSimulationECBSystem;

System update lists are protected / readonly, so the only option remains is reflection?

I feel like the better solution is just create your own command buffer system and use that instead

My goal is to run monobehaviour update after ECS simulation is done. I cannot use that unfortunately.

Custom monobehaviour update manager is made into one of the systems I want to put into AfterSimulationGroup;

I don’t get why that stops you from putting a buffer system within simulation?

BeginSimulationBufferSystem
YourSystem1
YourSystem2
YourBufferSystem [use this]
YourSystem3
EndSimulationBufferSystem [don’t use this]

Is the same thing as

BeginSimulationBufferSystem
YourSystem1
YourSystem2
EndSimulationBufferSystem [use this]
YourSystem3

Backward compatibility? I guess.
If something not mine, e.g. from plugin will change entities, those changes will not propagate correctly to the monobehaviours update.

Okay, so I’ve managed to order it like I want to.

  • Had to discard EndSimulationEntitiyCommandBufferSystem via bootstrap;
  • Re-added it to the LateSimulationGroup instead via bootstrap;
  • AfterSimulationGroup runs last now;
    6121859--667112--upload_2020-7-23_15-10-40.png

No reflection needed, and I’ll get a warning if something is not ordering correctly, which will at least will give me a hint what’s wrong.
Probably not the best solution, but it gets jobs done.

What’s wrong with just doing

[UpdateInGroup(typeof( SimulationSystemGroup ), OrderLast = true)]
[UpdateAfter(typeof(EndSimulationEntityCommandBufferSystem))]
public class AfterSimulationSystemGroup : ComponentSystemGroup { }

6122396--667199--Capture.PNG

4 Likes

It works! I haven’t think of using both OrderLast and UpdateAfter at the same time. Thanks.

I think I’ve tried that, and it just spit out warnings that EndSimulationEntityCommandBufferSystem is in the different update group. I’ll try that again once I can. Thanks for the suggestion.

Yeah, it does work now. Wtf?
6123074--667319--upload_2020-7-23_20-17-49.png

Okay, I got it. If the OrderLast is not set to true it just does this:

Ignoring invalid [UpdateAfter] attribute on EntitiesExt.UpdateGroups.AfterSimulationGroup because Unity.Entities.EndSimulationEntityCommandBufferSystem belongs to a different ComponentSystemGroup.
This attribute can only order systems that are children of the same ComponentSystemGroup.
Make sure that both systems are in the same parent group with [UpdateInGroup(typeof(Unity.Entities.SimulationSystemGroup)].

Which is weird, and probably a bug, unless intended.