Reputation: 1494
I've been looking everywhere for this, apparently Google forgot about getting the metadata tags associated with a leaderboard score.
In their Official Github unity plugin Documentation, they clearly stated:
To post a score and include a metadata tag use the Play Game Services instance directly:
And this worked just great, but now after a lot of searching i think that there is no way that you can get this Metadata Tag back from the leaderboard!.
Also from the official documentation:
You can load scores from a leaderboard using this function:
PlayGamesPlatform.Instance.LoadScores(lId,
leaderboardStart,
scoresToDisplay,
leaderboardType,
leaderboardTimeSpan,
(LeaderboardScoreData data) => {
for (int i = 0; i < data.Scores.Length; i++)
{
IScore score = data.Scores[i];
//handle where you want to save the scores
}
});
Can anyone help about how to get the score metadata tag?
Upvotes: 0
Views: 724
Reputation: 1494
I finally figured this out, for anyone who's trying to do what i wanted, here's the solution:
First you have to assign a metadata tag to the score that you want to report like this:
public void ReportScoreToLeaderboard(string leaderboardId, int score)
{
PlayGamesPlatform.Instance.ReportScore(score, leaderboardId, "SantaCharacter", (bool success) => {
// handle success or failure
});
}
Then when you want to get the score with the tag just cast the IScore to PlayGamesScore like so:
PlayGamesPlatform.Instance.LoadScores(lId,
leaderboardStart,
scoresToDisplay,
leaderboardType,
leaderboardTimeSpan,
(LeaderboardScoreData data) => {
for (int i = 0; i < data.Scores.Length; i++)
{
//Just cast the IScore to PlayGamesScore :)
PlayGamesScore score = (PlayGamesScore) data.Scores[i];
float scoreValue = score.value;
string tag = score.metaData;
//store them and do what you want with them
}
}
);
I Hope this will help someone.
Upvotes: 0