Skip to content

Instantly share code, notes, and snippets.

@xjjon
Created April 25, 2018 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xjjon/2bf90deae852f777783faca081f94ed1 to your computer and use it in GitHub Desktop.
Save xjjon/2bf90deae852f777783faca081f94ed1 to your computer and use it in GitHub Desktop.
using System;
using Newtonsoft.Json;
using UnityEngine;
using Object = System.Object;
public static class JSONLoader {
public static Object LoadData(String dataPath, Type type)
{
TextAsset jsonText = Resources.Load<TextAsset>(dataPath);
return LoadData(jsonText, type);
}
public static Object LoadData(TextAsset textAsset, Type type)
{
Debug.Log("Loading " + textAsset + " as " + type);
Object obj = JsonConvert.DeserializeObject(textAsset.text, type);
return obj;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment