【发布时间】:2017-11-04 19:41:39
【问题描述】:
我在 Google Play 上发布了一个简单的游戏。当玩家赢得比赛时,他的分数应该在排行榜中增加。我的问题是当玩家赢得游戏时,应用程序停止。我认为问题出在PlayGamesPlatform.Instance.LoadScores,因为当我删除这部分时,没有人有问题。另外,我想注意到并不是每个玩家在游戏中都有这样的问题。这个问题只发生在那些从未赢得比赛的人身上(他们在排行榜上没有得分)。所以,PlayGamesPlatform.Instance.LoadScores 只适用于那些已经在排行榜上得分的人。
我的脚本:
PlayGamesPlatform.Instance.LoadScores(GPGSIds.leaderboard_rating, GooglePlayGames.BasicApi.LeaderboardStart.PlayerCentered, 1, GooglePlayGames.BasicApi.LeaderboardCollection.Public, GooglePlayGames.BasicApi.LeaderboardTimeSpan.AllTime, (GooglePlayGames.BasicApi.LeaderboardScoreData data) =>
{
long score;
if (long.TryParse(data.PlayerScore.formattedValue, out score))
Social.ReportScore(score + 50, GPGSIds.leaderboard_rating, (bool success) => { });
else
Social.ReportScore(50, GPGSIds.leaderboard_rating, (bool success) => { });
});
【问题讨论】:
-
你可以尝试将所有玩家的分数设置为默认 0,以便尚未玩过的玩家可以调用 loadScores 吗?
-
@noogui 谢谢。它帮助了我
-
吉!很高兴听到它对您有用。
标签: c# unity5 google-play-games unity2d