Add a new score
Add or update a score for a player in a leaderboard.
Read time 1 minuteLast updated 22 days ago
To add or update an entry for the player in the specified leaderboard, use the
AddPlayerScoreAsyncpublic async void AddScore(string leaderboardId, int score){ var playerEntry = await LeaderboardsService.Instance .AddPlayerScoreAsync(leaderboardId, score); Debug.Log(JsonConvert.SerializeObject(playerEntry));}
Add a new score with metadata
To add a score with metadata, use theMetadataAddPlayerScoreOptionsIf a score that has stored metadata is updated with null metadata, the new metadata value will be null.[Serializable]public class ScoreMetadata{ public string levelName; public int timeTaken;}public async void AddScoreWithMetadata(string leaderboardId, int score){ var scoreMetadata = new ScoreMetadata { levelName = "LEVEL_01", timeTaken = 120 }; var playerEntry = await LeaderboardsService.Instance .AddPlayerScoreAsync( leaderboardId, score, new AddPlayerScoreOptions { Metadata = scoreMetadata } ); Debug.Log(JsonConvert.SerializeObject(playerEntry));}