Add a new score

To add or update an entry for the player in the specified leaderboard, use the AddPlayerScoreAsync method.

C#

public async void AddScore()
{
    var playerEntry = await LeaderboardsService.Instance
        .AddPlayerScoreAsync(leaderboardId, 102);
    Debug.Log(JsonConvert.SerializeObject(playerEntry));
}

Add a new score with metadata

To add or update an entry with associated metadata, use the Metadata option in the AddPlayerScoreOptions configuration object:

C#

public async void AddScoreWithMetadata()
{
    var metadata = new Dictionary<string, string>() { {"team", "red"} };
    var playerEntry = await LeaderboardsService.Instance
        .AddPlayerScoreAsync(
            leaderboardId,
            102,
            new AddPlayerScoreOptions { Metadata = new Dictionary<string, string>(){{ "team", "red" }}});
    Debug.Log(JsonConvert.SerializeObject(playerEntry));
}

If a score that has stored metadata is updated with null metadata, the new metadata value will be null.