我正在设置一个排行榜服务,该服务是用GooglePlayGames应用编程接口实现的。我的身份验证和显示排行榜有效,但我将分数发布到排行榜的脚本不起作用。我已经看了很长一段时间了,似乎发布分数的语法总是一样的,我也有。
void Start()
{
AuthenticateUser();
}
void AuthenticateUser()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
Social.localUser.Authenticate((bool success) =>
{
if (success == true)
{
Debug.Log("Logged in to Google play");
}
else
{
Debug.Log("There was an error login in to Google Play");
}
});
}
public static void PostToLeaderboard(long newScore)
{
Social.ReportScore(10, GPGSIds.leaderboard_highscore, (bool success) =>
{
if (success == true)
{
Debug.Log("Score were sucessfully added to leaderboard");
}
else
{
Debug.Log("Unable to post score to leaderboard");
}
});
}这是我的代码,用于验证并将分数发布到排行榜。我在代码Social.ReportScore函数调用中硬编码了10。
你知道为什么会这样吗?leaderboardUI出现了,但没有分数。
发布于 2019-05-22 01:48:56
在调用leaderboardUI方法之前,请确保运行PostToLeaderboard(long newScore)方法来更新排行榜。
在这里,在这种情况下,您可以尝试这个。
puplic void leaderboardUI() {
PostToLeaderboard(long newScore);
// your code to show leaderboard
}https://stackoverflow.com/questions/56038699
复制相似问题