public void GetCloudLastSavedMetadataAsync(Action <CloudMetadata> onPeekResult) { if (!Social.localUser.authenticated) { SushiDebug.LogFormat("GetCloudSavedAccountData: not authenticated"); onPeekResult(CloudMetadata.Invalid); return; } #if !NO_GPGS var savedGameClient = PlayGamesPlatform.Instance.SavedGame; if (savedGameClient != null) { Open(savedGameClient, true, OnSavedGameOpenedAndReadConflictResolve, (status, game) => { if (status == SavedGameRequestStatus.Success) { // handle reading or writing of saved game. SushiDebug.LogFormat("GetCloudSavedAccountData: Save game open (read) success! Filename: {0}", game.Filename); savedGameClient.ReadBinaryData(game, (status2, data2) => { if (status == SavedGameRequestStatus.Success) { // handle processing the byte array data SushiDebug.LogFormat("GetCloudSavedAccountData success! - Data size: {0} bytes", data2.Length); try { var remoteSaveDict = PlatformSaveUtil.DeserializeSaveData(data2); var cloudMetadata = new CloudMetadata { level = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_KEY), levelExp = PlatformSaveUtil.GetInt32FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_LEVEL_EXP_KEY), gem = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_GEM_KEY), riceRate = PlatformSaveUtil.GetBigIntegerFromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.ACCOUNT_RICE_RATE_KEY), saveDate = PlatformSaveUtil.GetInt64FromRemoteSaveDict(remoteSaveDict, PlatformSaveUtil.SAVE_DATE_KEY) }; onPeekResult(cloudMetadata); } catch { SushiDebug.LogFormat("GetCloudSavedAccountData: Exception at deserialization"); onPeekResult(CloudMetadata.Invalid); } } else { SushiDebug.LogFormat("GetCloudSavedAccountData: ReadBinaryData error! - {0}", status2); onPeekResult(CloudMetadata.Invalid); } }); } else { PlatformSaveUtil.LogCloudLoadSaveError(string.Format( "GetCloudSavedAccountData: OpenWithAutomaticConflictResolution error! - {0}", status)); onPeekResult(CloudMetadata.Invalid); } }); } else { PlatformSaveUtil.LogCloudLoadSaveError("GetCloudSavedAccountData: savedGameClient null"); onPeekResult(CloudMetadata.Invalid); } #endif }
public void GetCloudLastSavedMetadataAsync(Action <byte[]> onPeekResult) { #if !NO_GPGS if (!PlatformLogin.IsAuthenticated) { PlatformInterface.instance.logger.LogFormat("GetCloudSavedAccountData: not authenticated"); onPeekResult(null); return; } var savedGameClient = PlayGamesPlatform.Instance.SavedGame; if (savedGameClient != null) { Open(savedGameClient, true, OnSavedGameOpenedAndReadConflictResolve, (status, game) => { if (status == SavedGameRequestStatus.Success) { // handle reading or writing of saved game. PlatformInterface.instance.logger.LogFormat( "GetCloudSavedAccountData: Save game open (read) success! Filename: {0}", game.Filename); savedGameClient.ReadBinaryData(game, (status2, data2) => { if (status == SavedGameRequestStatus.Success) { // handle processing the byte array data PlatformInterface.instance.logger.LogFormat( "GetCloudSavedAccountData success! - Data size: {0} bytes", data2.Length); try { onPeekResult(data2); } catch { PlatformInterface.instance.logger.LogFormat( "GetCloudSavedAccountData: Exception at deserialization"); onPeekResult(null); } } else { PlatformInterface.instance.logger.LogFormat( "GetCloudSavedAccountData: ReadBinaryData error! - {0}", status2); onPeekResult(null); } }); } else { platformSaveUtil.LogCloudLoadSaveError( $"GetCloudSavedAccountData: OpenWithAutomaticConflictResolution error! - {status}"); onPeekResult(null); } }); } else { platformSaveUtil.LogCloudLoadSaveError("GetCloudSavedAccountData: savedGameClient null"); onPeekResult(null); } #endif }