Submitting Scores

To submit leaderboard scores you first need to initialize it (as explained on the previous page). Once the leaderboard is initialized, use the code below to submit a score:

[SerializeField]
SteamLeaderboards steamLeaderboards;

IEnumerator AsyncPostScoreToLeaderboard()
{
    steamLeaderboards.UpdateScoreToCurrentLeaderboard(1000);

    while (steamLeaderboards.IsPostingLeaderboardScore)
    {
        yield return null;
    }

    Debug.Log("Score submitted!");
    
    // Do what you want from here
}

The method AsyncPostScoreToLeaderboard() is a Coroutine because calls to the Leaderboard API are asynchronous

Unlike other assets, we will always check that the submitted score is the best before we send it to the leaderboard, which means you can call this method whenever you want in complete safety

Last updated