Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved [Feature Request] Getting total entries count

Discussion in 'Leaderboards' started by Brogan89, Aug 13, 2023.

  1. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    243
    I can't find a way to get the total number of leaderboard entries.
    It could be returned as metadata with the original leaderboard entries request if that's easier.

    Cheers
     
  2. GabKBelmonte

    GabKBelmonte

    Unity Technologies

    Joined:
    Dec 14, 2021
    Posts:
    49
    Hey Brogan,

    What endpoint / API are you using? Client / Get player scores with offset and limit?
     
  3. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    243
    Hey, I'm using the package:
    com.unity.services.leaderboards: 1.0.0

    The leaderboard shows the top ten entries using
    LeaderboardsService.Instance.GetScoresAsync
    with offset: 0, limit: 10

    We then show the player's score if outside the top ten using
    LeaderboardsService.Instance.GetPlayerScoreAsync
    which is fine.
    But we also want to show out of total entries. i.e. 15th / 2000 or whatever.
    Unless I've missed something as far as I can see there isn't a quick way of getting total entries without going through every page of the leaderboard which isn't ideal.

    I'm hoping for a method like
    GetTotalScores()
    or
    GetMetaData()
    which returns a struct of any metadata for the leaderboard which would be more extensible. Is something like this possible?

    Cheers
     
  4. GabKBelmonte

    GabKBelmonte

    Unity Technologies

    Joined:
    Dec 14, 2021
    Posts:
    49
    Hey Brogan,

    Asked the team, this is what the pointed me towards:
    """
    So the GetScoresAsync (docs) already returns a total field on the LeaderboardScoresPage return object (docs).
    """
     
    Brogan89 likes this.
  5. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    243
    Brilliant. I missed that. That works for me. Thanks :)