private static void Postfix(string slotName, UserStorageUtils.LoadOperation loadOperation) { byte[] bytes; if (loadOperation.GetSuccessful()) { if (loadOperation.files.TryGetValue(DeathRun.SaveFile, out bytes)) { DeathRunSaveData saveData = new DeathRunSaveData(); if (DeathRunSaveData.LoadFromBytes(bytes, out saveData)) { DeathRunUtils.RegisterSave(slotName, saveData); } } } }
private static IEnumerator LoadInternal <SaveDataT>(string fileName, Action <SaveDataT> onSuccess) { var userStorage = PlatformUtils.main.GetUserStorage(); List <string> files = new List <string> { fileName }; UserStorageUtils.LoadOperation loadOperation = userStorage.LoadFilesAsync(SaveLoadManager.main.GetCurrentSlot(), files); yield return(loadOperation); if (loadOperation.GetSuccessful()) { var stringData = Encoding.ASCII.GetString(loadOperation.files[fileName]); SaveDataT saveData = JsonConvert.DeserializeObject <SaveDataT>(stringData); onSuccess(saveData); } else { Console.WriteLine("Load Failed: " + loadOperation.errorMessage); } }
private IEnumerator DeserializeCoroutine(string path) { Debug.Log($"trying to load {path}"); UserStorage userStorage = PlatformUtils.main.GetUserStorage(); UserStorageUtils.LoadOperation loadOperation = userStorage.LoadFilesAsync(SaveLoadManager.main.GetCurrentSlot(), new List <string>() { path }); yield return(loadOperation); if (loadOperation.GetSuccessful()) { string json = Encoding.ASCII.GetString(loadOperation.files[path]); BaseClockSaveData saveData = JsonConvert.DeserializeObject <BaseClockSaveData>(json); m_UseSystemTime = saveData.usesSystemTime; UseSystemTimeSet(m_UseSystemTime); Debug.Log($"{path} loaded"); } }