Search Unity

Unity Leaderboards not working

Discussion in 'Unity Analytics' started by Masthead, Feb 15, 2019.

  1. Masthead

    Masthead

    Joined:
    Apr 17, 2015
    Posts:
    2
    Hi all,
    I am trying to make a custom leader board menu and take the data from android leader boards.
    I am using the sample code :

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


    I also tried with the PlayGamesPlatform like this:

      PlayGamesPlatform.Instance.LoadScores (
    <your_leaderboard_ID_here>,
    LeaderboardStart.PlayerCentered,
    1,
    LeaderboardCollection.Public,
    LeaderboardTimeSpan.AllTime,
    (LeaderboardScoreData data) => {
    Debug.Log (data.Valid);
    Debug.Log (data.Id);
    Debug.Log (data.PlayerScore);
    Debug.Log (data.PlayerScore.userID);
    Debug.Log (data.PlayerScore.formattedValue);
    });
    }


    But I never get any data out from both...

    I have not forgotten to use this as well:
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
    .EnableSavedGames()
    .RequestEmail()
    .RequestServerAuthCode(false)
    .RequestIdToken()
    .Build();

    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.Activate();

    SignIn();

    private void SignIn()
    {
    Social.localUser.Authenticate((bool success) =>
    {
    SceneManager.LoadScene("MainMenu");
    });
    }


    when I use
    Social.ShowLeaderboardUI();
    The google play ui shows with no problem ONLY when I upload it to google play...
    I gave uploaded the apk to alpha release on google play - would that make a problem ?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You might want to post in the Scripting forum, this forum is for Unity Analytics and is not associated with leaderboards.