- Home /
Question by
firatercis · Nov 20, 2016 at 01:40 PM ·
google play gamesleaderboardleaderboards
Google Play Games Services- Leaderboard Problem
Hi,
I use google play games plugin for Unity.
I have a LeaderBoardManager class to wrap up the leaderboard functionality. The function get scores() is as follows:
void LoadUsersAndDisplay(int leaderBoardID,ILeaderboard lb,LeaderBoardEntry[] resultingEntries)
{
// get the user ids
List<string> userIds = new List<string>();
foreach(IScore score in lb.scores) {
userIds.Add(score.userID);
}
// load the profiles and display (or in this case, log)
Social.LoadUsers(userIds.ToArray(), (users) =>
{
string status = "Leaderboard loading: " + lb.title + " count = " +
lb.scores.Length;
int currentUserIndex = 0;
foreach(IScore score in lb.scores) {
IUserProfile user = users[currentUserIndex];
status += "\n" + score.formattedValue + " by " +
(string)(
(user != null) ? user.userName : "**unk_" + score.userID + "**");
resultingEntries[currentUserIndex] = new LeaderBoardEntry(score.rank,user.userName,score.value);
currentUserIndex++;
}
// Get the local user score
LeaderBoardEntry localUserEntry = new LeaderBoardEntry(lb.localUserScore.rank, Social.localUser.userName,lb.localUserScore.value);
// Notify the observers about the receiving of the scores
foreach (LeaderBoardObserver currentObserver in observers) {
Debug.Log ("Notifying the leaderboard observer");
currentObserver.OnScoresReceived (leaderBoardID,resultingEntries,localUserEntry);
}
Debug.Log(status);
});
}
public void getScores(int lbID){
ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard();
lb.id = leaderboards [lbID].lbOfficialID;
lb.timeScope = TimeScope.AllTime;
lb.userScope = UserScope.Global;
LeaderBoardEntry[] resultingEntries = null;
lb.LoadScores(ok =>
{
if (ok) {
resultingEntries = new LeaderBoardEntry[lb.scores.Length];
LoadUsersAndDisplay(lbID,lb,resultingEntries);
}
else {
Debug.Log("Error retrieving leaderboardi");
}
});
Debug.Log ("Have " + observers.Count + " lbObservers");
}
I have the following Console output:
However, my most up to date world record is 79 points. ShowLeaderBoardGUI() function shows it correct:
Where can I be wrong?
lbconsoleoutput.jpg
(139.4 kB)
lbgui.jpg
(77.0 kB)
Comment