我有一個在Google Play上發佈的簡單遊戲。當玩家贏得比賽時,他的分數應該在排行榜上增加。我的問題是,當玩家贏得比賽時,應用停止。我認爲這個問題在PlayGamesPlatform.Instance.LoadScores
因爲當我刪除這部分,沒有人有問題。另外,我想要注意的是,並不是每個玩家在遊戲中都有這樣的問題。這個問題只發生在那些沒有贏過比賽的人(他們在排行榜上沒有得分)。所以,PlayGamesPlatform.Instance.LoadScores
只適用於那些在排行榜中已經有一定分數的人。如何在Unity中加載分數?
我的腳本:
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
@noogui謝謝。它幫助我 – irakliy01
Gj!很高興聽到它爲你工作。 – noogui