I’m trying to coordinate one Monobehaviour (PhysicsQuery) and two systems (PreloaderSystem and ActorSystem) forced to update inside their respective Monobehaviour wrappers, like this
public class PreloaderRunner : MonoBehaviour
{
private void Update()
{
World.Active.GetOrCreateManager<PreloaderUpdateGroup>().Update();
}
}
I used the script ordering function under Project Settings to set the ordering of the three Monobehaviours to PhysicsQuery → PreloaderSystem → ActorSystem. The rationale is that I want to schedule all possible physics queries in PreloaderSystem and have the calculations take place in worker threads while ActorSystem does its own work. The order is basically
- PhysicsQuery copies all data from PreloaderSystem.
- PreloaderSystem schedules a new batch of physics calculations
- ActorSystem uses the results from PhysicsQuery to calculate movement, decisions, shooting, in the main thread while PreloaderSystem’s jobs are running in the background
This SHOULD prevent scheduling errors, but I’m receiving errors saying that Unity cannot schedule a job in PhysicsQuery due to a job from PreloaderSystem being already scheduled. This shouldn’t be possible! Project Settings specifies that PhysicsQuery runs before PreloaderSystem, and all of PreloaderSystem’s jobs should be completed by the EndFrameBarrier. Even the Profiler shows that the order of execution is as specified. What could be the reason for this scheduling conflict? Are the PreloaderSystem jobs from the previous frame somehow still running in the current frame as PhysicsQuery prepares to read from PreloaderSystem’s NativeContainers?