- Home /
google leaderboard troubleshooting
Hey, I've been working on a little game, and decided I was to the point where I needed to get some leaderboards in there, I went with the google play leaderboards for ease of use, and after a psychotic amount of issues I eventually got everything working, its now building without error, and everything's going perfectly, except now the leaderboard simply wont show up. So first off I'm gonna show you my code, its pretty simple stuff I just pulled from a tutorial I found.
using UnityEngine;
using System.Collections;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
using UnityEngine.SceneManagement;
public class HighScoresBehavior : MonoBehaviour
{
#region PUBLIC_VAR
public string leaderboard;
#endregion
#region DEFAULT_UNITY_CALLBACKS
void Start()
{
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
PlayGamesPlatform.Activate();
}
#endregion
#region BUTTON_CALLBACKS
/// <summary>
/// Login In Into Your Google+ Account
/// </summary>
public void LogIn()
{
Social.localUser.Authenticate((bool success) =>
{
if (success)
{
Debug.Log("Login Sucess");
}
else
{
Debug.Log("Login failed");
}
});
}
/// <summary>
/// Shows All Available Leaderborad
/// </summary>
public void OnShowLeaderBoard()
{
// Social.ShowLeaderboardUI (); // Show all leaderboard
((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboard); // Show current (Active) leaderboard
}
/// <summary>
/// Adds Score To leader board
/// </summary>
public void OnAddScoreToLeaderBorad()
{
if (Social.localUser.authenticated)
{
Social.ReportScore(1, leaderboard, (bool success) =>
{
if (success)
{
Debug.Log("Update Score Success");
}
else
{
Debug.Log("Update Score Fail");
}
});
}
}
/// <summary>
/// On Logout of your Google+ Account
/// </summary>
public void OnLogOut()
{
((PlayGamesPlatform)Social.Active).SignOut();
}
#endregion
public void exit()
{
SceneManager.LoadScene(0);
}
}
So basically I drop into a new scene (to simplify things I just made the highscores in their own scene that you navigate to from the main menu), then you're presented (for now) a few buttons, first is a debug button that (should) add a point on the leaderboard, a log into google option, a log out of google option, and a show leaderboards option, also a quit to menu button. The only button that functions is the log in button, it loads up on my phone googles options to log in, and I log in no problem, heres where it's weird. My logcat swears that I didn't log in successfully.
(Hope I didn't include any sensitive info) But on my phone it works fine, also whenever I press any button (except quit) it doesn't say a word, acts like I didn't press a thing.
Any thoughts? suggestions?
UPDATE: Just now I tried again and its just throwing login failed (from debug.log) each time, and this time its legitimately not showing that I logged in on my phone.
Answer by Bonkahe · Jul 21, 2016 at 11:58 AM
Hey, figured this one out, for anyone going down this same path, public string leaderboard;
Needs to be set to your leaderboard ID, you can find it in the developer console to the right of the individual leaderboard icon. Good Luck
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Achievements Google Play. 1 Answer
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer