Skip to content

koyashiro/generic-data-container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenericDataContainer

A generic and type-safe wrapper for DataContainer.

Installation

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.

Creator Companion

  1. Enable the koyashiro package repository.

    image

  2. Find GenericDataContainer from the list of packages and install any version you want.

VPM CLI

  1. Execute the following command to install the package.

    vpm add package net.koyashiro.genericdatacontainer

DataList<T>

Example

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();
    }
}

DataDictionary<TKey, TValue>

Example

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
    }
}

About

A generic and type-safe wrapper for DataContainer.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages