1234567891011121314151617181920212223 |
- using System;
- using UnityEngine;
- namespace Plugins.CxShine.net
- {
- // 出处 :https://forum.unity3d.com/threads/how-to-load-an-array-with-jsonutility.375735/#post-2585129
- public class JsonHelper
- {
- public static T[] getJsonArray<T>(string json)
- {
- var newJson = "{ \"array\": " + json + "}";
- var wrapper = JsonUtility.FromJson<Wrapper<T>>(newJson);
- return wrapper.array;
- }
- [Serializable]
- private class Wrapper<T>
- {
- public T[] array;
- }
- }
- }
|