Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Save and Load stats from Google Play Games?

Discussion in 'Android' started by AlexTselikas, Dec 5, 2015.

  1. AlexTselikas

    AlexTselikas

    Joined:
    Jun 16, 2013
    Posts:
    3
    Hi guys, i have implemented google play services on my game for the leaderboard and the highscore is posted everytime you die(if you get a high score higher than the previous).Everything works fine until i update the app or re-install it as it deletes the local file used for high score saving.Is there any way to retrieve the highscore from the google play leaderboard?I am using Google's Play Games Services for Unity plugin on GitHub.

    Thanks!

    This is my code:

    Code (CSharp):
    1.  public void PostToLeaderboard()
    2.     {
    3.         Social.ReportScore(ScoreManager.instance.highScoreCount, "CgkI5ZnTgM0TEAIQAQ", (bool success) =>
    4.         {
    5.             //Added score to the leaderboard;
    6.         });
    7.     }
    8.     public void ShowLeaderboard()
    9.     {
    10.         ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI("CgkI5ZnTgM0TEAIQAQ");
    11.     }
     
  2. dfpisani

    dfpisani

    Joined:
    Jul 18, 2015
    Posts:
    3
    same problem here

    i wanna load the score into a variable when the player reinstall the game or change the device
     
  3. dfpisani

    dfpisani

    Joined:
    Jul 18, 2015
    Posts:
    3
    anybody can help us?
     
  4. DanielFF

    DanielFF

    Joined:
    Aug 29, 2012
    Posts:
    41
    From Play Game Services GitHubs page:

    Code (CSharp):
    1.  PlayGamesPlatform.Instance.LoadScores(
    2.             leaderboardId,
    3.             LeaderboardStart.PlayerCentered,
    4.             100,
    5.             LeaderboardCollection.Public,
    6.             LeaderboardTimeSpan.AllTime,
    7.             (data) =>
    8.             {
    9.                 mStatus = "Leaderboard data valid: " + data.Valid;
    10.                 mStatus += "\n approx:" +data.ApproximateCount + " have " + data.Scores.Length;
    11.             });