Method Reinterpret
Reinterpret<U>()
Returns a dynamic buffer of a different type, pointing to the same buffer memory.
Declaration
public DynamicBuffer<U> Reinterpret<U>() where U : unmanaged
Returns
Type | Description |
---|---|
DynamicBuffer<U> | A dynamic buffer of the reinterpreted type. |
Type Parameters
Name | Description |
---|---|
U | The reinterpreted type. |
Remarks
No memory modification occurs. The reinterpreted type must be the same size in memory as the original type.
Examples
Entities.ForEach((DynamicBuffer<FloatBufferElement> buffer) =>
{
DynamicBuffer<float> floatBuffer = buffer.Reinterpret<float>();
for (int i = 0; i < floatBuffer.Length; i++)
{
floatBuffer[i] = i * 1.2f;
}
}).ScheduleParallel();
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If the reinterpreted type is a different size than the original. |