- Home /
Leaderboard is not displaying any score after tapping on it. I always see only one message "Unbelievable there is no score to display".
Can anybody help me with Updating score to Leaderboard for the Google Play. Actually everything is working fine for me, but I am stuck when trying to post the score to the leaderboard in Google Play. I have created a Submit button to post the score to Leaderboard. But the score is not showing up.
Here is my my code :
using System.Collections; using GooglePlayGames; using GooglePlayGames.BasicApi; using UnityEngine.SocialPlatforms; using UnityEngine; using UnityEngine.UI;
public class MainMenuEvents : MonoBehaviour { private Text signInButtonText; private Text authStatus; private GameObject ldrButton; public string leaderboard;
public static MainMenuEvents instance;
private void Awake()
{
instance = this;
DontDestroyOnLoad(gameObject);
}
public void Start()
{
signInButtonText =
GameObject.Find("signInButton").GetComponentInChildren<Text>();
authStatus = GameObject.Find("authStatus").GetComponent<Text>();
ldrButton = GameObject.Find("ldrButton");
PlayGamesPlatform.Instance.Authenticate(SignInCallback, true);
}
public void Update()
{
ldrButton.SetActive(Social.localUser.authenticated);
}
public void SignInCallback(bool success)
{
if (success)
{
Debug.Log("(Player) Signed in!");
signInButtonText.text = "Sign out";
authStatus.text = "Signed in as: " + Social.localUser.userName;
}
else
{
Debug.Log("(Player) Sign-in failed...");
signInButtonText.text = "Sign in";
authStatus.text = "Sign-in failed";
}
}
public void SignIn()
{
if (!PlayGamesPlatform.Instance.localUser.authenticated)
{
PlayGamesPlatform.Instance.Authenticate(SignInCallback, false);
}
else
{
PlayGamesPlatform.Instance.SignOut();
signInButtonText.text = "Sign In";
authStatus.text = "";
}
}
#region Leaderboards
public void AddScoreToLeaderboard()
{
if (Social.localUser.authenticated)
{
Social.ReportScore(100, leaderboardId, (bool success) =>
{
if (success)
{
Debug.Log("Update Score Success");
}
else
{
Debug.Log("Update Score Fail");
}
});
}
}
public void ShowLeaderboards()
{
if (PlayGamesPlatform.Instance.localUser.authenticated)
{
PlayGamesPlatform.Instance.ShowLeaderboardUI(GPGSIds.leaderboard_high_score);
}
else
{
Debug.Log("Cannot show leaderboard: not authenticated");
}
#endregion
}
}
Please help! I am stuck on leaderboard
Hi,did you solved your this problem because I am completely stuck on it. Please help !! Thanks in advance