public void LoadFromGameKitData(UM_iSavedGameMetadata game, bool parseMeta, Action <UM_SavedGameDataLoadResult> callback) { var isn_meta = (UM_IOSSavedGameMetadata)game; ISN_GKLocalPlayer.LoadGameData(isn_meta.NativeMeta, (result) => { UM_SavedGameDataLoadResult loadResult; if (result.IsSucceeded) { if (parseMeta) { var meta = new UM_SaveInfo(); meta.SetProgressValue(BitConverter.ToInt64(result.BytesArrayData, 0)); meta.SetPlayedTimeMillis(BitConverter.ToInt64(result.BytesArrayData, 8)); var userData = new byte[result.BytesArrayData.Length - 16]; Array.Copy(result.BytesArrayData, 16, userData, 0, userData.Length); loadResult = new UM_SavedGameDataLoadResult(userData, meta); } else { loadResult = new UM_SavedGameDataLoadResult(result.BytesArrayData, new UM_SaveInfo()); } } else { loadResult = new UM_SavedGameDataLoadResult(result.Error); } callback.Invoke(loadResult); }); }
public void LoadFromPlayerPrefs(UM_iSavedGameMetadata game, bool parseMeta, Action <UM_SavedGameDataLoadResult> callback) { var editorGamesList = LoadSavesList(); var editorGame = editorGamesList.GetByName(game.Name); UM_SavedGameDataLoadResult loadResult; if (editorGame != null) { var BytesArrayData = editorGame.GameData.ToBytes(); if (parseMeta) { var meta = new UM_SaveInfo(); meta.SetProgressValue(BitConverter.ToInt64(BytesArrayData, 0)); meta.SetPlayedTimeMillis(BitConverter.ToInt64(BytesArrayData, 8)); var userData = new byte[BytesArrayData.Length - 16]; Array.Copy(BytesArrayData, 16, userData, 0, userData.Length); loadResult = new UM_SavedGameDataLoadResult(userData, meta); } else { loadResult = new UM_SavedGameDataLoadResult(BytesArrayData, new UM_SaveInfo()); } } else { var error = new SA_Error(100, "Saved game with name: " + game.Name + " wasn't found"); loadResult = new UM_SavedGameDataLoadResult(error); } EditorSaveGames(editorGamesList); SA_Coroutine.WaitForSeconds(1.5f, () => { callback.Invoke(loadResult); }); }