Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SavedGameMetadata is closed after CommitUpdate #3299

Open
RaphaelNSG opened this issue May 21, 2024 · 1 comment
Open

SavedGameMetadata is closed after CommitUpdate #3299

RaphaelNSG opened this issue May 21, 2024 · 1 comment
Labels

Comments

@RaphaelNSG
Copy link

RaphaelNSG commented May 21, 2024

Describe the bug
Always when a call savedGameClient.CommitUpdate(savedGameMetadata, updatedMetadata, binaryValues, OnSavedGameWritten); the SavedGameMetadata is closed.

Steps to reproduce the behavior:

  1. Initialize the Google Play plugin
  2. Open a saved game with savedGameClient.OpenWithAutomaticConflictResolution
  3. Try to save any values using savedGameClient.CommitUpdate...
  4. Check if the SavedGameMetadata is opened

Expected behavior
After commit and update a new binary the metadata continues opened.

Observed behavior
After commit and update a new binary the metadata is closed

Versions

  • Unity version: 2021.3.27f1
  • Google Play Games Plugin for Unity version: V0.11.01

Additional context

ISavedGameMetadata savedGameMetadata;
PlayGamesPlatform.Instance.Authenticate(OnAuthenticate);

void OnAuthenticate(SignInStatus status)
{
    if (status == SignInStatus.Success)
    {
        Debug.Log("Auth success");

        PlayGamesPlatform.Instance.SavedGame.OpenWithAutomaticConflictResolution(
            "my-game",
            DataSource.ReadCacheOrNetwork,
            ConflictResolutionStrategy.UseMostRecentlySaved,
            OnSavedGameOpened);
    }
    else
    {
        Debug.Log("Auth error");
    }
}

void OnSavedGameOpened(SavedGameRequestStatus status, ISavedGameMetadata game)
{
    if (status == SavedGameRequestStatus.Success)
    {
        Debug.Log("Open save game success");

        savedGameMetadata = game;
        SavedGameMetadataUpdate.Builder builder = new SavedGameMetadataUpdate.Builder().
                WithUpdatedDescription($"Saved game at {DateTime.Now}");
            SavedGameMetadataUpdate updatedMetadata = builder.Build();

            using (var memorystream = new MemoryStream())
            {
                var bf = new BinaryFormatter();
                bf.Serialize(memorystream, "Values to test the save");
                byte[] binaryValues = memorystream.ToArray();

                Debug.Log($"IsOpen: {savedGameMetadata.IsOpen}"); // Is always `true`
                PlayGamesPlatform.Instance.SavedGame.CommitUpdate(savedGameMetadata, updatedMetadata, binaryValues, OnSavedGameWritten);
            }
    }
    else
    {
        Debug.Log("Open save game error");
    }
}

void OnSavedGameWritten(SavedGameRequestStatus status, ISavedGameMetadata game)
{
    if (status == SavedGameRequestStatus.Success)
    {
       Debug.Log($"IsOpen: {savedGameMetadata.IsOpen}"); // Is always `false`
    }
    else
    {
        Debug.Log("Write save game error");
    }
}
@RaphaelNSG RaphaelNSG added the bug label May 21, 2024
@smile616
Copy link
Collaborator

That works as intended. There are no plans to change the behavior in the nearest future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants