我正在Unity中实施Google Play游戏排行榜,我正在创建用于查看排行榜的用户界面,因为我正在使用:
SDK:https://github.com/playgameservices/play-games-plugin-for-unity
Google Play服务版: 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服务无法使用它,mTitle在LeaderboardScoreData中无效。
可以告诉我如何修复此令牌错误吗?
我可以使用其他方法获得其他分数吗?我无法再次使用LoadScore,因为再次开始加载用户周围的用户,或者如果我能做到这一点,我不知道该怎么做。
答案 0 :(得分:0)
对于未来的问题,最后修复是:
在https://console.developers.google.com/apis/dashboard中激活 Google Play服务,令牌将正常运作。