This repository has been archived following the launch of DataList. We strongly recommend using DataList for future projects.
If you're in need of a generic version of DataList, consider using the GenericDataContainer repository as a potential resource.
List implementation for UdonSharp.
To use this package, you need to add my package repository. Please read more details here.
Please install this package with Creator Companion or VPM CLI.
-
Enable the
koyashiro
package repository. -
Find
UdonList
from the list of packages and install any version you want.
-
Execute the following command to install the package.
vpm add package net.koyashiro.udonlist
UdonList
example for a string
.
In addition, UdonList<int>
, UdonList<float>
, UdonList<bool>
,
UdonList<UdonSharpBehaviour>
, UdonList<object>
, and so on can be used.
using UnityEngine;
using UdonSharp;
using Koyashiro.UdonList;
public class UdonListSample : UdonSharpBehaviour
{
private void Start()
{
var list = UdonList<string>.New(); // Same as C# `new List<string>();`
list.Add("first"); // ["first"]
list.Add("second"); // ["first", "second"]
list.Add("third"); // ["first", "second", "third"]
list.Remove("second"); // ["first", "third"]
// List to array
var convertedArray = list.ToArray();
// Array to list
var convertedList = UdonList<string>.New(convertedArray);
// Alternative foreach
for (var i = 0; i < convertedList.Count(); i++)
{
Debug.Log(list.GetValue(i)); // "first", "third"
}
}
}