docs.unity3d.com
    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 : struct
    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.

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023