【问题标题】:can't load scores from leaderboard无法从排行榜加载分数
【发布时间】:2019-06-28 01:33:34
【问题描述】:

我正在使用 google play 游戏服务插件在我的统一游戏中设置排行榜系统。

我想加载分数以便将它们集成到我的自定义 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 警告:从获取返回的错误:-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);

            }
        }
    });
}

【问题讨论】:

  • 您能否显示比上述更详细的错误,以便社区检查?
  • 我已经弄明白了,刚刚去掉了旧的google play游戏配置,重新开始,现在一切正常!

标签: c# unity3d google-play-games leaderboard


【解决方案1】:

【讨论】:

    【解决方案2】:

    在这上面花了几个小时后,我发现我的问题是我的游戏使用了另一个应用程序的排行榜 ID。 所以它失败了这个“未经授权的错误”,但是没有给出确切的原因。

    发生这种情况的原因是因为统一中的游戏配置正在缓存旧值。当您打开它时 - 它具有正确的 ID,但是在生成的 GPGSids.cs 文件中 - 存在错误的 ID。

    解决方案只是通过重新保存配置来重新生成它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-10
      • 1970-01-01
      • 2015-07-30
      • 2018-07-18
      • 2017-02-24
      • 2016-08-14
      • 2021-03-04
      相关资源
      最近更新 更多