Hi,
Passing a persistent allocated nativearray to a job’s constructor then calling Slice on it always throws. ArgumentException: Slice may not be used on a restricted range array
I tried Slice(0,1) to make sure I am not overflowing the index and still got the same exception.
public struct Job : IJobParallelFor
{
public NativeArray<Vector3> summonedPos;
public void Execute(int index)
{
var ns = summonedPos.Slice(0, 1);
//ArgumentException: Slice may not be used on a restricted range array
//I checked and positive that summonedPos length is more than 1
}
}
public class JobManager : MonoBehaviour
{
private NativeArray<SpawnPoint.ParallelData> _spawnersArray;
private Job _job;
public void Initialize()
{
_summonedPos = new NativeArray<Vector3>(_spawnPoints.Length * 50, Allocator.Persistent);
_job = new Job
{
summonedPos = _summonedPos
};
}
Thanks for advance.