public static List <int> GetAcquiredEndings() { // 1 string jsonEndingPath = string.Format("{0}/{1}.json", Application.persistentDataPath, endingSaveDataName); if (File.Exists(jsonEndingPath)) { EndingSaveData save = JsonUtility.FromJson <EndingSaveData>(File.ReadAllText(jsonEndingPath)); return(save.SeenEndings); } return(new List <int>()); }
public static void SaveEndingProgress(int endingNumber) { List <int> currentEndingProgress = GetAcquiredEndings(); if (!currentEndingProgress.Contains(endingNumber)) { currentEndingProgress.Add(endingNumber); } EndingSaveData data = new EndingSaveData(currentEndingProgress); // 2 string jsonEndingPath = string.Format("{0}/{1}.json", Application.persistentDataPath, endingSaveDataName); Debug.Log(jsonEndingPath); string jsonData = JsonUtility.ToJson(data, true); File.WriteAllText(jsonEndingPath, jsonData); Debug.Log("Ending Progress Saved"); }