Quick answer: Remove [ReadOnly] or replace with [WriteOnly] for output buffers. Pick the attribute that matches actual access pattern.
You declare an output array [ReadOnly] by reflex. Inside Execute you write to it. Burst safety throws.
The Fix
public struct ApplyVelocity : IJobParallelFor {
[ReadOnly] public NativeArray<float3> Velocities; // read-only input
[WriteOnly] public NativeArray<float3> OutPositions; // write-only output
public float Dt;
public void Execute(int i) {
OutPositions[i] = Velocities[i] * Dt;
}
}
For RW (read then write same index), drop both attributes — safety serializes the buffer against other consumers.
Verifying
Schedule job. No exception. Two parallel jobs reading the same Velocities run concurrently. Two jobs writing to OutPositions serialize.
“Right attribute. Right access. Safety happy.”
Related Issues
For NativeArray dispose, see dispose timing. For Burst determinism, see determinism.
Mark intent. Safety green.