But how do I “get” the score to be displayed again within the game? the problem is that whenever I update my app on Play Store, the local score returns to “0”, but the ones on the Google Play Service Leaderboard is still intact, so I am looking for a way to get that Leaderboard value back to the game.
Basically, data.PlayerScore.UserID will give you the player’s unique ID, data.PlayerScore.formattedValue will give you the highest score of the player that was submitted to the Google Play leaderboards. data.Id will give you the leaderboard ID and so on.
@Ronggowisnu Not sure if you are still interested, but this worked for me using the latest Google Play Games Unity plug-in:
using GooglePlayGames;
using GooglePlayGames.BasicApi;
PlayGamesPlatform.Instance.LoadScores("leaderboard_ID",
LeaderboardStart.PlayerCentered,
1,
LeaderboardCollection.Public,
LeaderboardTimeSpan.AllTime,
(LeaderboardScoreData data) => {
DisplayText.text = "You have " + data.PlayerScore.formattedValue + " points!";
}
);
What it is doing basically is loading the scores from the Leaderboard you identify, centered on the player, and only collecting one row (1), looking at the public leaderboard, all time scores.
It then returns data, of which you collect the PlayerScore portion, and use the formattedValue as that represents legible values (ie: 1, 25, 547, etc…). Since you only collected that one row of data you only have the one player’s score.
ILeaderboard leaderboard = Social.CreateLeaderboard();
leaderboard.timeScope = TimeScope.AllTime;
leaderboard.id = "YOUR_APP_LEADERBORAD_ID";
leaderboard.LoadScores(success =>
{
if (success)
{
// you can retrieve the score of local user here
long localUserScore = leaderboard.localUserScore.value;
}
});