“NativeSlice SliceWithStride” method looks like below, but I think there are some error process.
// Convert NativeSlice<T> to a new NativeSlice<U> to Contain type U element, start from "offset"。
public unsafe NativeSlice<U> SliceWithStride<U>(int offset) where U : struct
{
NativeSlice<U> nativeSlice;
nativeSlice.m_Buffer = this.m_Buffer + offset;
nativeSlice.m_Stride = this.m_Stride; // Use old type stride?? or should use size of Type U
nativeSlice.m_Length = this.m_Length; // Length should recalculate by Type U too !
if (offset < 0)
throw new ArgumentOutOfRangeException(nameof (offset), "SliceWithStride offset must be >= 0");
if (offset + UnsafeUtility.SizeOf<U>() > UnsafeUtility.SizeOf<T>())
throw new ArgumentException("SliceWithStride sizeof(U) + offset must be <= sizeof(T)", nameof (offset));
nativeSlice.m_MinIndex = this.m_MinIndex;
nativeSlice.m_MaxIndex = this.m_MaxIndex;
nativeSlice.m_Safety = this.m_Safety;
return nativeSlice;
}
Pls check it. Thx!
Best regards