Initializing Leaderboards

Before submitting scores or retrieving data, you will need to initialize a leaderboard. To do this, use the code below:

[SerializeField]
SteamLeaderboards steamLeaderboards;

IEnumerator AsyncInitializeLeaderboard() {
    steamLeaderboards.SetLeaderboard("My Awesome Leaderboard", 
        ELeaderboardSortMethod.k_ELeaderboardSortMethodDescending,
        ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric);
    
    while (steamLeaderboards.IsSearchingForLeaderboard)
    {
        yield return null;
    }
    
    Debug.Log("Leaderboard Initialized!");
    
    // Do what you want from here
}

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

Cool! Once we have the leaderboard in our hands, we can submit scores or retrieve data.

Last updated