24 lines
507 B
C#
24 lines
507 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace WZ
|
|
{
|
|
public static class DataUtils
|
|
{
|
|
[System.Serializable]
|
|
private class Wrapper<T>
|
|
{
|
|
public T[] items;
|
|
}
|
|
|
|
public static T[] FromJsonArray<T>(string json)
|
|
{
|
|
string wrappedJson = $"{{\"items\":{json}}}";
|
|
Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(wrappedJson);
|
|
return wrapper.items;
|
|
}
|
|
}
|
|
}
|
|
|