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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Social.LoadScores and huge leaderboards question

Discussion in 'iOS and tvOS' started by cez, May 7, 2015.

  1. cez

    cez

    Joined:
    Mar 3, 2015
    Posts:
    1
    Hi all,

    I'm implementing leaderboards into a game and decided to use Social unity plugin for game center and as I couldn't find a proper explanation anywhere, can someone tell me please how does the Social.LoadScores exactly work? My biggest concern is what would happen when the leaderboard gets really huge(10k+ entries), does this function actually returns all the scores in a table?
    What I exactly need is the percentile of a players rank(user is better than x%) so I'd need the info on how many scores are actually in the table (IScore[].length?) and current user rank(IScore.rank).
    Is there any other/better way to do that?

    Any help appreciated.
    Thanks
     
  2. iwHiteRabbiT

    iwHiteRabbiT

    Joined:
    Feb 15, 2011
    Posts:
    47
    Ok the documentation isn't really clear here...

    In fact, you have to create an ILeaderBoard instance which will be used to make queries with some options (like which LeaderBoard, from which rank, how many scores, etc)

    http://docs.unity3d.com/ScriptReference/Social.CreateLeaderboard.html
    http://docs.unity3d.com/ScriptReference/SocialPlatforms.Range.html

    Something like :

    Code (csharp):
    1.  
    2. leaderboard = Social.CreateLeaderboard();
    3. leaderboard.id = "Leaderboard012";
    4. leaderboard.range = new Range(fromValue, valueCount); // Here we go
    5. leaderboard.LoadScores(result =>
    6. {
    7.     Debug.Log("Received " + leaderboard.scores.Length + " scores");
    8.     foreach (IScore score in leaderboard.scores)
    9.         Debug.Log(score);
    10. });
    11.  
     
    Last edited: Oct 6, 2015
    crandellbr and michael22 like this.