I’m having trouble with this code that used to work
Debug.Log($"{tileIndexStartLocal.Length} {testIndex}");
var c = tileIndexStartLocal[testIndex];
Debug.Log("test");
First output is “288 4” and I never get the “test” outputted in the console.
I get this error:
IndexOutOfRangeException: Index 4 is out of restricted IJobParallelFor range [0…3] in ReadWriteBuffer.
ReadWriteBuffers are restricted to only read & write the element at the job index. You can use double buffering strategies to avoid race conditions due to reading & writing in parallel to the same elements from a job.
this happens inside an Entities.ForEach, tileIndexStartLocal is a persistent NativeArray that is set up in Update function before the Entities.ForEach. In the ForEach I only read from this array.
Yay!! That’s it, now it works! Thanks a million! I wasn’t aware of WithReadOnly and this worked before with a previous version of the Entities package.