public static void NewLoadTrackFromPath(string path, ref TrackP track) { if (System.IO.File.Exists(path)) { bool sucess = NewLoadFromFile(path, ref track); if (!sucess) { Debug.LogError("Failed to load " + path); } } else { Debug.Log("No path " + path + " found"); } }
static bool NewLoadFromFile(string path, ref TrackP track) { bool sucess = true; try { string fileContents = System.IO.File.ReadAllText(path); track = JsonUtility.FromJson <TrackP>(fileContents); } catch (System.Exception e) { Debug.LogError(e); sucess = false; } return(sucess); }
public static void NewSerializeAndSave(TrackP track, string path) { string serializedBank = JsonUtility.ToJson(track, true); System.IO.File.WriteAllText(path, serializedBank); }