• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by $$anonymous$$ · Nov 13, 2012 at 03:59 PM · c#socialgamecenterleaderboards

GameCenterPlatform - Load leaderboards with custom parameters

Hello everyone :)

I'm implementing GameCenter using Unity's GameCenterPlatform.

I am aware of the default implementation using LoadScores, like the documentation suggests:

 Social.LoadScores("Leaderboard01", scores => {
     if (scores.Length > 0) {
         Debug.Log ("Got " + scores.Length + " scores");
         string myScores = "Leaderboard:\n";
         foreach (IScore score in scores)
             myScores += "\t" + score.userID + " " + score.formattedValue + " " + score.date + "\n";
         Debug.Log (myScores);
     }
     else
         Debug.Log ("No scores loaded");
 });

The documentation states:

This uses default leaderboard parameters.

Unfortunately I am not aware what these "default parameters" are, I'm not sure what scores is returned from the leaderboard. Is there anyone who is aware of a way to retrieve scores based on your own custom search query?

Thank you for your time :)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image solid_ · Jul 31, 2016 at 12:18 PM 0
Share

Debug in Xcode says.... LoadScores retrieve only 10 scores from rank 1 to 10 using default parameters

Use m_Leaderboard.range = new Range (m_Leaderboard.localUserScore.rank, range);

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by abeldantas · Aug 18, 2017 at 08:50 PM

In Unity 5.6 you can do stuff like:

 void ShowScoresForToday()
 {
     // OutputField is a Unity text element I'm using to debug this on the device
     OutputField.text = "";
 
     var leaderboardID = "leaderboard";
     var log = string.Format( "Showing top score for leaderboard with id: '{0}'", leaderboardID );
     Debug.Log( log );
     OutputField.text = log;
 
     var leaderboard = Social.CreateLeaderboard();
     leaderboard.id = leaderboardID;
     leaderboard.timeScope = TimeScope.Today;
     leaderboard.LoadScores( success =>
     {
         var scores = leaderboard.scores;
         if ( scores.Length > 0 )
         {
             foreach ( var score in scores )
             {
                 var logLine = string.Format( "User with id '{0}' has a score of {1}, rank is {2}",
                     score.userID, score.value, score.rank );
                 OutputField.text += "\n" + logLine;
             }
         }
         else
         {
             Debug.LogError( "No scores registered" );
         }
     } );
 }


You have to initialize the Leaderboard object before querying, with the Social.CreateLeaderboard()

The filters are, hm, limited - https://docs.unity3d.com/ScriptReference/SocialPlatforms.ILeaderboard.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Did Social.LoadUsers() stop working? 3 Answers

Social Api causing crashes 2 Answers

How can I show a specific leaderboard in iOS GameCenter? 2 Answers

When will Social.ReportScore() fail? 0 Answers

Game Center login issue 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges