ECS job and use of static variables

Hi all,

From the documentation
“Accessing static data from a job circumvents all safety systems. If you access the wrong data, you might crash Unity, often in unexpected ways.”

So I am wondering, does that mean that you cannot use static data INSIDE the job, but still use it on the OnUpdate method? I do not see how this would be a problem, but I really want to make sure before continuing with my project :slight_smile:

Thank youuuuuuuu
ps:
// OnUpdate runs on the main thread.
protected override JobHandle OnUpdate(JobHandle inputDependencies)

You can use static in OnUpdate.
You can use readonly static of blittables in jobs, which they will be copied.

thanks a lot :slight_smile: I can now sleep again hahaah

You might also wanna have a look at: Burst User Guide | Burst | 1.2.3

1 Like

oh sweeet, I have focused so much on ECS that I did not even check the documentation for burst! thanks!

That one is even newer than typing @latest into the URL. I just found it too.

I am worry about “static restrict” too.
At first glance it seems good to limited developer to only access immutable static data in job.
But in practice, the ability to access “any” kind of data is very helpful in multi-thread program, and it also safe as long as developer initialize static data in its static constructor and never change it.