Answer the question
In order to leave comments, you need to log in
How to instantiate an object from a function's type parameter?
There is a method in the Utils class
public static T getJsonList<T>(string json)
{
string newJson = "";
T obj = new T();
Debug.Log("getJsonList " + json);
if(json.Substring(0, 1) != "{") {
newJson = "{ \"array\": " + json + "}";
} else {
newJson = json;
}
T wrapper = JsonUtility.FromJson<T>(newJson);
return wrapper;
}
callback(Utils.JsonHelper.getJsonList<T>(www.downloadHandler.text));
RequestManager.apiGET<Models.GameModel>("gamble", param, resp => {
//...
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question