public static Type LoadResourcesJson <Type>(string path) { string jsonText = Resources.Load <TextAsset>(path).ToString(); if (String.IsNullOrEmpty(jsonText)) { Debug.LogWarning("LoadJson Error - Path:" + path); } return(JsonUtilityExtend.FromJson <Type>(jsonText)); }
public static Type LoadPersistentJson <Type>(string path) where Type : new() { path = Application.persistentDataPath + "/" + path + ".json"; if ((File.Exists(path) || Directory.Exists(path))) { string textData = File.ReadAllText(path); Type listData = JsonUtilityExtend.FromJson <Type>(textData); if (listData == null) { Debug.LogWarning("LoadJson Empty - Path:" + path); return(new Type()); } else { return(listData); } } File.WriteAllText(path, ""); return(new Type()); }