docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)