TransWikia.com

Leaderboard not working in Unity

Game Development Asked by single arrow games on December 11, 2021

I’m trying to create a leaderboard for my game. I have the game created and added the leaderbaord using cloudonce. I have also created the app on google play console and linked the app to the game services. I have followed the following tutorial to create the leaderboard: Leaderboard tutorial

I have followed the exact same instruction as given in the tutorial. Once the game is over, the leaderboard button is activated. I have attached LeaderboardsButton script(this script comes with the CloudOnce package) to the leaderboard button.
Here is the code in the game over panel for getting the score:

void OnEnable()
{
    DisplayGameOverScore();
}
void DisplayGameOverScore()
{        
    gameOverScore.text = ((int)gameManager.playerScore).ToString();       
    gameOverHighScore.text = PlayerPrefs.GetInt("HighScore", 0).ToString();
    CloudOnceServices.instance.SubmitScoretoLeaderboard(PlayerPrefs.GetInt("HighScore", 0));
}

This is the CloudOnceServices script as per the tutorial:

public static CloudOnceServices instance;

private void Awake()
{
    TestSingleton();
}

private void TestSingleton()
{
    if (instance != null)
    {
        Destroy(gameObject);
        return;
    }
    instance = this;
    DontDestroyOnLoad(gameObject);
}

public void SubmitScoretoLeaderboard(int score)
{

    Leaderboards.HighScore.SubmitScore(score);
}

I have attahced this script to an empty game object along with the InitializeCloudOnce script(this is provided with the CloudOnce package).

I have also created an alpha test on googleplay. Once I open the link and start the game, the google play services console open and when I hit the leaderboard button, google play services console loads but after that nothing happens. It just goes back to the game. I read that other people ran into similar issues and the advise given was to check if the SHA1 certificate fingerprint is the same in app signing under release management and the credentials in GoogleApis. They both match. I’m not sure what the issue is?

One Answer

It's probably an authentication problem. In case you're allowing Google to sign your APKs it means only the builds downloaded from the Playstore will be authenticated. If you build any new APKs without uploading them to your developer account you have to add your local build's SHA1 cert to the API console and link it to your app on the Google developer console before it can authenticate users.

Answered by Yuushabio on December 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP