[Feature Request] NativeArray.Reinterpret<type>(int byte_offset)

That would let me reinterpret big structs into a single float, so I can set them from the array

struct MyBigTypeReinterpretedToFloat {
    float somefloat;//not changed
    float otherfloat;
    float yetanotherfloat;//not changed
}
var MyBigTypeReinterpretedToFloat = chunk.GetNativeArray(MyBigTypeReinterpretedToFloatAccess ).Reinterpret<float>(4);
MyBigTypeReinterpretedToFloat [i] = new_otherfloat_value;

I think NativeSlice gives you the stride functionality you are looking for.

You can only get Stride, you can’t set it. You also can only set the slice lenght (number of elements), but not it’s stride it seems.

1 Like

turns out NativeArray.Reinterpret<float>(16) works, quite risky, but works just fine
if your struct have 4 floats and you only want to write to one of them, the code above works, and then you index it by YourArray[i*4] = newvalue to write to the first float, YourArray[i*4+1] = newvalue to write to the second float, and so forth