Created
November 27, 2018 09:14
-
-
Save q8f13/1a967c7a7485004241400da27a6a8edf to your computer and use it in GitHub Desktop.
add json array support to unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JsonHelper | |
{ | |
public static T[] getJsonArray<T>(string json) | |
{ | |
string newJson = "{ \"array\": " + json + "}"; | |
Wrapper<T> wrapper = UnityEngine.JsonUtility.FromJson<Wrapper<T>>(newJson); | |
return wrapper.array; | |
} | |
[System.Serializable] | |
private class Wrapper<T> | |
{ | |
public T[] array; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment