Hello, I am trying to create the following struct inside a job and get the above error.
public struct JobSafeHeightMap {
//Convert 2D array into 1D, we will have to convert back.
public NativeArray<float> array;
public readonly int size1;
public readonly int size2;
public readonly bool complete;
public JobSafeHeightMap(float[,] array, int size1, int size2, bool complete) {
this.array = new NativeArray<float>(size1 * size2, Allocator.TempJob);
for(int i = 0; i < size1; i++) {
for(int j = 0; j < size2; j++) {
this.array[i * size1 + j] = array[i, j];
}
}
this.size1 = size1;
this.size2 = size2;
this.complete = complete;
}
public float[,] GetArray() {
float[,] returnFloat = new float[size1, size2];
for(int i = 0; i < size1; i++) {
for (int j = 0; j < size2; j++) {
returnFloat[i, j] = array[i * size1 + j];
}
}
return returnFloat;
}
}
The line the error points to is:
this.array = new NativeArray<float>(size1 * size2, Allocator.TempJob);
Anyone know why this doesn’t work?
Thanks!