Add a new score
Add or update a score for a player in a leaderboard.
읽는 시간 1분최근 업데이트: 12시간 전
To add or update an entry for the player in the specified leaderboard, use the method.
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 the option on the configuration object:
MetadataAddPlayerScoreOptions[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)); }
If a score that has stored metadata is updated with null metadata, the new metadata value will be null.
Leaderboard score metadata can be up to 1024 bytes (1 KB).