Question by
Potato_Pepper · Sep 04, 2017 at 11:50 PM ·
iosscoregamecenterleaderboards
GameCenter Leaderboard Reporting Scores
Right, so this is driving me insane. I have implemented a GameCenter leaderboard in my game to view high scores. GameCenter authentication works and I can view the leaderboard, but no scores are showing up despite having reported a score.
My main code for the leaderboard:
public class SocialPlatformController : MonoBehaviour {
public static SocialPlatformController controller;
private static string LEADERBOARD_ID = "MyHighScoreLeaderboard";
public bool m_loginSuccessful;
void Awake()
{
if (controller == null)
{
DontDestroyOnLoad(gameObject);
controller = this;
}
else if (controller != this)
{
Destroy(gameObject);
}
}
// Use this for initialization
void Start () {
Social.localUser.Authenticate(ProcessAuthentication);
}
public void ProcessAuthentication (bool success) {
if (success) {
Debug.Log("Authenticated user.");
}
else
{
Debug.Log("Failed to authenticate user.");
}
m_loginSuccessful = success;
}
public void DisplayLeaderboard() {
//Social.ShowLeaderboardUI();
GameCenterPlatform.ShowLeaderboardUI(LEADERBOARD_ID, TimeScope.AllTime);
}
public void SetHighScore(int score) {
long highScore = (long)score;
if (m_loginSuccessful)
{
Social.ReportScore(highScore, LEADERBOARD_ID, success =>
{
Debug.Log(success ? "Reported score successfully." : "Failed to report score.");
});
}
else
{
Social.localUser.Authenticate(ProcessAuthentication);
if (m_loginSuccessful)
{
Social.ReportScore(highScore, LEADERBOARD_ID, success =>
{
Debug.Log(success ? "Reported score successfully." : "Failed to report score.");
});
}
}
}
}
When I report a score, I do something like this:
//Yes, my score has to be an object for various reasons
object highScore = 50.015f;
//Convert the object into an int, to simplify the score
int convertedHighScore = (int)(float)highScore;
//Report the score
SocialPlatformController.controller.SetHighScore(convertedHighScore);
The leaderboard is live and attached to my app, which also just went live. Please help!
Comment
I've also had this same issue. I get a 'true' response from the callback function yet no scores get added to the leaderboard.