I want to pass a function that builds objects from a string that represents the type and a JSON string.
How do I do this dynamically? I’d rather not create a massive switch case to identify the type string.
void BuildUnknownObjectFromJSON(string objclassname, string jsonstring){
Type type = Type.getType(objclassname);
// this?
GameObject obj = new GameObject() as type;
obj = JsonUtility.FromJson<type>(jsonstring);
// Or this?
var obj = JsonUtility.FromJsonOverwrite(jsonstring) as type;
// Or this?
object obj = Activator.CreateInstance(type);
JsonUtility.FromJsonOverwrite(jsonstring, obj)
}