public override void OnEnter() { GameServices.SavedGames.OpenWithAutomaticConflictResolution(savedGameName.Value, (openedSavedGame, error) => { if (string.IsNullOrEmpty(error)) { if (openedSavedGame != null) { // Saved game found. // Convert base64 string to binary data and write it to the found saved game. byte[] binaryData = Convert.FromBase64String(data.Value); // Update saved game's info. SavedGameInfoUpdate.Builder builder = new SavedGameInfoUpdate.Builder(); if (!string.IsNullOrEmpty(newDescription.Value)) { builder.WithUpdatedDescription(newDescription.Value); } if (newPngCoverImage.Value != null) { Texture2D tex = newPngCoverImage.Value as Texture2D; builder.WithUpdatedPngCoverImage(tex.EncodeToPNG()); } if (newPlayedTime.Value > 0) { builder.WithUpdatedPlayedTime(TimeSpan.FromSeconds(newPlayedTime.Value)); } // Write data. GameServices.SavedGames.WriteSavedGameData(openedSavedGame, binaryData, builder.Build(), OnSavedGameUpdated); } else { // No saved game found with the specified name. isSuccess.Value = false; errorDescription.Value = "Not found saved game with name " + savedGameName; Fsm.Event(eventTarget, isNotSuccessEvent); Finish(); } } else { isSuccess.Value = false; errorDescription.Value = error; Fsm.Event(eventTarget, isNotSuccessEvent); Finish(); } }); }
public void WriteSavedGameData(SavedGame savedGame, byte[] data, Action <SavedGame, string> callback) { SavedGameInfoUpdate infoUpdate = new SavedGameInfoUpdate.Builder().Build(); WriteSavedGameData(savedGame, data, infoUpdate, callback); }