我正在 Unity 中实现 Google Play 游戏排行榜,我正在制作我的 UI 以查看排行榜,为此,我正在使用:
SDK:https ://github.com/playgameservices/play-games-plugin-for-unity
谷歌播放服务版本:9.4.0
当我使用PlayGamesPlatform类中的LoadScores方法时,可以返回用户、分数等,但是,为了获得更多用户,我需要使用LoadMoreScores方法,这就是问题所在。
当我使用LoadMoreScores方法时,在日志中,Android 会返回它并且不返回更多玩家:
E/Volley: [5566] BasicNetwork.performRequest: Unexpected response code 410 for https://www.googleapis.com/games/v1/leaderboards/LeaderboardID/window/PUBLIC?timeSpan=ALL_TIME&language=en_US&maxResults=10&pageToken=LeaderboardNextToken&returnTopIfAbsent=true
W/LeaderboardAgent: Failed to retrieve leaderboard scores for GameID LeaderboardID ALL_TIME
com.android.volley.ServerError
at com.android.volley.toolbox.BasicNetwork.performRequest(:com.google.android.gms:163)
at iss.performRequest(:com.google.android.gms:64)
at com.android.volley.NetworkDispatcher.run(:com.google.android.gms:113)
W/LeaderboardAgent: {"errors":[{"domain":"global","reason":"PaginationTokenInvalid","message":"The passed token does not match the arguments of the request. Token: LeaderboardNextToken"}],"code":410}
我在 Unity3D 中针对此错误的代码是:
/// <summary>
/// Loads the scores using the provided parameters.
/// </summary>
/// <param name="leaderboardId">Leaderboard identifier.</param>
/// <param name="start">Start either top scores, or player centered.</param>
/// <param name="rowCount">Row count. the number of rows to return.</param>
/// <param name="collection">Collection. social or public</param>
/// <param name="timeSpan">Time span. daily, weekly, all-time</param>
/// <param name="callback">Callback to invoke when completed.</param>
PlayGamesPlatform.Instance.LoadScores(
"LeaderboardID", //The original ID obviously
LeaderboardStart.PlayerCentered,
10,
LeaderboardCollection.Public,
LeaderboardTimeSpan.AllTime,
(success) =>
{
leaderboardScoreData = success;
//Do Anything...
}
);
在LoadScores之后的一个按钮中......
/// <summary>
/// Loads more scores.
/// </summary>
/// <remarks>This is used to load the next "page" of scores. </remarks>
/// <param name="token">Token used to recording the loading.</param>
/// <param name="rowCount">Row count.</param>
/// <param name="callback">Callback invoked when complete.</param>
PlayGamesPlatform.Instance.LoadMoreScores(
leaderboardScoreData.NextPageToken,
10,
(success) =>
{
//Looking the returned object
Debug.Log("Load more scores info: " + success.ToString());
//Do Anything...
}
);
那Debug.Log返回:
I/Unity: Load more scores info: [LeaderboardScoreData: mId=LeaderboardID, mStatus=SuccessWithStale, mApproxCount=0, mTitle=]
下一页令牌和上一页令牌具有正确的令牌,但 Google Play 服务无法使用该令牌,LeaderboardScoreData 中的 mTitle 无效。
谁能告诉我如何解决这个令牌错误?
我可以通过其他方法获得其他分数吗?我不能再次使用 LoadScore,因为重新开始加载用户周围的用户,或者如果我能做到,我不知道该怎么做。