我正在使用谷歌游戏服务插件在我的团结游戏中设置排行榜系统。
我想加载得分,以便将它们集成到我的自定义LeaderbordUI中,我按照文档并使用了ILeaderboard.LoadScores但它不起作用。
当我检查logcat我得到这个:
02-04 11:03:56.580:W / Unity(18969):!!! [Play Games Plugin DLL] 02/04/19 11:03:56 +01:00警告:从fetch返回错误:-108
我尝试使用“Social.LoadScores”和“PlayGamesPlatform.Instance.LoadScores”方法加载Score,但我收到了同样的警告。
PS:当我使用Social.ShowLeaderboardUI()时,它会显示我的排行榜。但是当我使用PlayGamesPlatform.Instance.ShowLeaderboardUI(LB_Stars.id)显示一个特定的排行榜时,它给了我“嗯,玩游戏中出了点问题”
public void LoadLeaderboard()
{
LB_Stars.LoadScores(ok =>
{
if (ok)
{
LoadUsersAndDisplay(LB_Stars);
}
else
{
Debug.Log("Error retrieving STARS leaderboard");
}
});
}
internal void LoadUsersAndDisplay(ILeaderboard lbStar)
{
Debug.Log("gonna load user and display them");
List<string> userIds = new List<string>();
foreach (IScore score in lbStar.scores)
{
userIds.Add(score.userID);
}
Social.LoadUsers(userIds.ToArray(), (users) =>
{
string status = "Leaderboard loading: " + lbStar.title + " count = " +
lbStar.scores.Length;
foreach (IScore score in lbStar.scores)
{
IUserProfile user = FindUser(users, score.userID);
if (user != null)
{
UserLeaderboardClone = Instantiate(UserLeaderboardPrefab);
UserLeaderboardClone.name = score.rank.ToString();
LeaderboardUserScript lbUser = UserLeaderboardClone.GetComponent<LeaderboardUserScript>();
lbUser.transform.SetParent(LBScrollview.content.transform, false);
FillUserInfo(lbUser, user, score);
}
}
});
}
花了几个小时对此,我的问题结果是我的游戏是使用来自另一个应用程序的排行榜ID。因此,这种“未经授权的错误”失败了,但没有给出确切的原因。
之所以发生这种情况,是因为统一中的游戏配置正在缓解旧的价值观。打开它时 - 它具有正确的ID,但是在生成的GPGSids.cs文件中 - 存在错误的ID。
解决方案只是通过重新保存配置来重新生成它。