Class DynamicArray<T> | Core RP Library | 7.2.1
docs.unity3d.com
    Show / Hide Table of Contents

    Class DynamicArray<T>

    Generic growable array.

    Inheritance
    Object
    DynamicArray<T>
    Namespace: UnityEngine.Rendering
    Syntax
    public class DynamicArray<T>
        where T : new()
    Type Parameters
    Name Description
    T

    Type of the array.

    Constructors

    DynamicArray()

    Constructor. Defaults to a size of 32 elements.

    Declaration
    public DynamicArray()

    DynamicArray(Int32)

    Constructor

    Declaration
    public DynamicArray(int size)
    Parameters
    Type Name Description
    Int32 size

    Number of elements.

    Properties

    Item[Int32]

    ref access to an element.

    Declaration
    public T this[int index] { get; }
    Parameters
    Type Name Description
    Int32 index

    Element index

    Property Value
    Type Description
    T

    The requested element.

    size

    Number of elements in the array.

    Declaration
    public int size { get; }
    Property Value
    Type Description
    Int32

    Methods

    Add(T)

    Add an element to the array.

    Declaration
    public int Add(in T value)
    Parameters
    Type Name Description
    T value

    Element to add to the array.

    Returns
    Type Description
    Int32

    The index of the element.

    Clear()

    Clear the array of all elements.

    Declaration
    public void Clear()

    Resize(Int32, Boolean)

    Resize the Dynamic Array. This will reallocate memory if necessary and set the current size of the array to the provided size.

    Declaration
    public void Resize(int newSize, bool keepContent = false)
    Parameters
    Type Name Description
    Int32 newSize

    New size for the array.

    Boolean keepContent

    Set to true if you want the current content of the array to be kept.

    In This Article
    • Constructors
      • DynamicArray()
      • DynamicArray(Int32)
    • Properties
      • Item[Int32]
      • size
    • Methods
      • Add(T)
      • Clear()
      • Resize(Int32, Boolean)
    Back to top
    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