docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method CopyFrom

    CopyFrom(NativeArray<T>)

    Copies all the elements from the specified native array into this dynamic buffer.

    Declaration
    public void CopyFrom(NativeArray<T> v)
    Parameters
    Type Name Description
    NativeArray<T> v

    The native array containing the elements to copy.

    Examples
    int[] sourceArray = { 1, 2, 3, 4, 5 };
    NativeArray<int> nativeArray = new NativeArray<int>(source, Allocator.Persistent);
    buffer.CopyFrom(nativeArray);

    CopyFrom(NativeSlice<T>)

    Copies all the elements from the specified native slice into this dynamic buffer.

    Declaration
    public void CopyFrom(NativeSlice<T> v)
    Parameters
    Type Name Description
    NativeSlice<T> v

    The native slice containing the elements to copy.

    Examples
    NativeSlice<int> nativeSlice = new NativeSlice<int>(nativeArray, 1, 3);
    buffer.CopyFrom(nativeSlice);

    CopyFrom(DynamicBuffer<T>)

    Copies all the elements from another dynamic buffer.

    Declaration
    public void CopyFrom(DynamicBuffer<T> v)
    Parameters
    Type Name Description
    DynamicBuffer<T> v

    The dynamic buffer containing the elements to copy.

    Examples
    buffer.CopyFrom(secondBuffer);

    CopyFrom(T[])

    Copies all the elements from an array.

    Declaration
    public void CopyFrom(T[] v)
    Parameters
    Type Name Description
    T[] v

    A C# array containing the elements to copy.

    Examples
    int[] integerArray = { 1, 2, 3, 4, 5 };
    buffer.CopyFrom(integerArray);
    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the given array is empty.

    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)