A generic and type-safe wrapper for DataContainer.
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
GenericDataContainer
from the list of packages and install any version you want.
-
Execute the following command to install the package.
vpm add package net.koyashiro.genericdatacontainer
using UnityEngine;
using UdonSharp;
using Koyashiro.GenericDataContainer;
public class DataListExample : UdonSharpBehaviour
{
public void Start()
{
DataList<int> list = DataList<int>.New();
list.Add(100);
list.Add(200);
list.Add(300);
Debug.Log(list.GetValue(0)); // 100
Debug.Log(list.GetValue(1)); // 200
Debug.Log(list.GetValue(2)); // 300
int[] array = list.ToArray();
}
}
using UnityEngine;
using UdonSharp;
using Koyashiro.GenericDataContainer;
public class DataDictionaryExample : UdonSharpBehaviour
{
public void Start()
{
DataDictionary<string, int> dic = DataDictionary<string, int>.New();
dic.SetValue("first", 100);
dic.SetValue("second", 200);
dic.SetValue("third", 300);
Debug.Log(dic.GetValue("first")); // 100
Debug.Log(dic.GetValue("second")); // 200
Debug.Log(dic.GetValue("third")); // 300
}
}