#How to schedule an IJobEntity after another one in different systems?

1 messages · Page 1 of 1 (latest)

soft berry
#

I got this error when trying to read NativeParallelMultiHashMap from another system.

InvalidOperationException: The previously scheduled job UnitSpatialSystem:IndexJob writes to the Unity.Collections.NativeParallelMultiHashMap2[System.Int32,System.Int32] IndexJob.JobData.Map. You are trying to schedule a new job UnitScanSystem:ScanJob, which reads from the same Unity.Collections.NativeParallelMultiHashMap2[System.Int32,System.Int32] (via ScanJob.JobData.Spatial.MMap). To guarantee safety, you must include UnitSpatialSystem:IndexJob as a dependency of the newly scheduled job.

Is there a way to schedule an IJobEntity after another one, even if they are in different systems?

shy ravine
#

put it into singleton component

#

and get via that singleton

soft berry
#

Yes, it is in a singleton .

shy ravine
#

so just use SystemAPI.GetSingleton to pass it

#

between systems

soft berry
#

var spatial = SystemAPI.GetSingleton<UnitSpatialSystem.Singleton>(); passing is not problem.

shy ravine
soft berry
#

yes

shy ravine
#

which is then passed to schedule of job

soft berry
#

private partial struct ScanJob : IJobEntity, IJobEntityChunkBeginEnd
{
[ReadOnly] public UnitSpatialSystem.Singleton Spatial; }

#

like this?

shy ravine
#

no

#

that's not what I meant

#

but if you don't write to it - you should specify that attribute

soft berry
#

I'm a bit confused.

shy ravine
#

use SystemAPI.GetSingleton/GetSingletonRW in each system that schedules jobs that uses that component (or native containers from that component)

soft berry
#

I finally understand. I will go and give it a try.

#

It worked. Thank you so much for your invaluable help !!!!!!