Need a way to access SingletonRO in ECS

Hi, I am following CodeMonkey’s tutorial on ECS (Unity DOTS 1.0 in 60 MINUTES! - YouTube).

About 44 mins into the video, we have a reoccurring error as we are accessing a component in read-Write reference( RefRW ) which was fetched using SystemAPI.GetSingletonRW.

Now I know we cannot write data in threads and it is unsafe. But if we access Unity.Mathematics.Random.NextFloat(f1,f2), can we just use ReadOnly( RefRO )? as the seed and value in random is updated by itself and we never have to write any value explicitly.

I tried searching SingletonRefRO get but I only got SystemAPI.GetSingleton and SystemAPI.GetSingletonEntity. So I am wondering is there a way to fetch a component(RandomComponent) which has only one instance active as a RefRO and still run the application. Any suggestion or advice would be very helpful.

I know we can suppress the error, but I would like to find a different approach without suppressing the errors.

About 44 mins into the video, we have a reoccurring error as we are accessing a component

It’s helpful to post the error message as details matter here

Now I know we cannot write data in threads and it is unsafe

Well technically we can, the problems starts when n>1 threads write to the same memory address
different values

But if we access Unity.Mathematics.Random.NextFloat(f1,f2), can we just use ReadOnly(RefRO)?

Even better - you don’t need to pass a complicated RW<Random> struct at all but pass it’s internal uint (seed) instead and recreate the struct at the destination with new Random(seed).NextFloat(f1,f2)

tip: poke/change the the original Random from the singleton to make sure it’s seed changes and you won’t get the identical “random” number every tick