VUdon - Array Extensions [](https://github.com/Varneon/VUdon-ArrayExtensions/stargazers) [](https://github.com/Varneon/VUdon-ArrayExtensions/releases) [](https://github.com/Varneon/VUdon-ArrayExtensions/releases/latest)

September 6, 2025 · View on GitHub

VUdon - Array Extensions GitHub Repo stars GitHub all releases GitHub tag (latest SemVer)

Collection of array extension methods compatible with UdonSharp 1.x which adds partial feature set from List

Important

Array Extensions' Add, AddRange, AddUnique, Insert, InsertRange, Remove, RemoveAt and RemoveRange methods are intended for use cases that meet the following criteria:

  • Array must be used instead of a DataList (Commonly due to frequent iteration per frame)
  • Methods listed above are invoked infrequently (They have a high performance cost in exchange for the ability to manipulate arrays)
MethodParametersReturnsDescription
AddTT[]Adds an item to an array
AddRangeT[]T[]Adds the elements of the specified collection to the end of the array
AddUniqueTT[]Adds an item to an array and ensures duplicates are not added
ContainsTboolDetermines whether an element is in the array
FirstOrDefaultTReturns the first element, or default value if the array is empty
GetElementTypeUdonTypeGets the element type of the array type
GetRangeInt, IntT[]Creates a shallow copy of a range of elements in the source
IndexOfT (Int, Int)IntReturns the zero-based index of the first occurrence of a value in the T[]
InsertInt, TT[]Inserts item to array at index
InsertRangeInt, T[]T[]Inserts the elements of a collection into the [] at the specified index
LastIndexOfT (Int, Int)IntReturns the zero-based index of the last occurrence of a value in the T[]
LastOrDefaultTReturns the last element, or default value if the array is empty
RemoveTT[]Removes item from array
RemoveAtIntT[]Removes item at index from array
RemoveRangeInt, IntT[]Removes a range of elements from the T[]
ResizeIntT[]Resizes array
ReverseT[]Reverses Array

Caution

For performance reasons this extension method library doesn't implement null checks! Please ensure the arrays you're accessing with the methods from this library are initialized.

Usage Demonstration

using UdonSharp;
using UnityEngine;
using Varneon.VUdon.ArrayExtensions;

public class UdonArrayExtensionDemo : UdonSharpBehaviour
{
    [SerializeField]
    private string[] strings;

    [SerializeField]
    private string[] range;

    [SerializeField]
    private string text;

    [SerializeField]
    private int index;

    [SerializeField]
    private int count;

    public void UsageDemo()
    {
        // Add item to array
        strings = strings.Add(text);

        // Add range of elements to array
        strings = strings.AddRange(range);
        
        // Check if item is contained in array
        Debug.Log(strings.Contains(text));

        // Get range of elements in array
        Debug.Log(string.Join("\n", strings.GetRange(index, count)));

        // Get the first index of element in array
        Debug.Log(strings.IndexOf(text));

        // Get the first index of element in array, starting at index
        Debug.Log(strings.IndexOf(text, index));

        // Get the first index of element in array in a range starting at index at the size of count
        Debug.Log(strings.IndexOf(text, index, count));

        // Insert item to array
        strings = strings.Insert(index, text);

        // Insert array of items to array
        strings = strings.InsertRange(index, range);

        // Get the last index of element in array
        Debug.Log(strings.LastIndexOf(text));

        // Get the last index of element in array, starting at index
        Debug.Log(strings.LastIndexOf(text, index));

        // Get the last index of element in array in a range starting at index at the size of count
        Debug.Log(strings.LastIndexOf(text, index, count));

        // Remove item from array
        strings = strings.Remove(text);

        // Remove item at index from array
        strings = strings.RemoveAt(index);

        // Remove range of elements from array
        strings = strings.RemoveRange(index, count);

        // Reverse array
        strings = strings.Reverse();

        // Get the first element in array
        Debug.Log(strings.FirstOrDefault());

        // Get the last element in array
        Debug.Log(strings.LastOrDefault());

        // Get the element type of a type
        Debug.Log(strings.GetType().GetElementTypeUdon());

        // Add unique item to array (if item exists in array, it won't be added)
        strings = strings.AddUnique(text);

        // Resize array
        strings = strings.Resize(index);
    }
}

Installation

Import with VRChat Creator Companion

Coming Soon™

Import with Unity Package Manager (git)

  1. In the Unity toolbar, select Window > Package Manager > [+] > Add package from git URL...
  2. Copy and paste the following link into the URL input field:
    https://github.com/Varneon/VUdon-ArrayExtensions.git?path=/Packages/com.varneon.vudon.array-extensions

Import from Unitypackage

  1. Download latest com.varneon.vudon.array-extensions.unitypackage from here
  2. Import the downloaded .unitypackage into your Unity project

Developed by Varneon with :hearts:

Twitter Follow YouTube Channel Subscribers GitHub followers