【问题标题】:Google play game services Leaderboard with custom UI using Unity3d plugin of google使用谷歌的 Unity3d 插件自定义 UI 的谷歌玩游戏服务排行榜
【发布时间】:2017-10-19 10:54:03
【问题描述】:

我们希望将所有排行榜数据显示到我们为游戏自定义创建的 UI 中。为此,我们想要访问最高得分信息,例如个人资料图片、得分和玩家姓名。

所有数据都将显示在我们自定义创建的 UI 中

我们正在使用以下 google 的 unity3d 插件 https://github.com/playgameservices/play-games-plugin-for-unity

请告诉我们如何访问我们游戏排行榜的所有玩家数据

【问题讨论】:

    标签: android unity3d unity5 google-play-games leaderboard


    【解决方案1】:

    您提供的链接包含有关如何使用该插件的实际文档。从Accessing Leaderboard data(你可以得到分数)到Getting Player names,提到你可以

    使用Social.LoadUsers()加载玩家资料

    您可以从那里获得IUserProfile 以从同一链接获得imageusername. 示例:

    internal void LoadUsersAndDisplay(ILeaderboard lb)
        {
            // get the user ids
            List<string> userIds = new List<string>();
    
            foreach(IScore score in lb.scores) {
                userIds.Add(score.userID);
            }
            // load the profiles and display (or in this case, log)
            Social.LoadUsers(userIds.ToArray(), (users) =>
                {
                    string status = "Leaderboard loading: " + lb.title + " count = " +
                        lb.scores.Length;
                    foreach(IScore score in lb.scores) {
                        IUserProfile user = FindUser(users, score.userID);
                        status += "\n" + score.formattedValue + " by " +
                            (string)(
                                (user != null) ? user.userName : "**unk_" + score.userID + "**");
                    }
                    Debug.log(status);
                });
        }
    

    话虽如此,如果您希望获得更详细和精确的示例,在 Stack Overflow 中将被视为过于宽泛,可能会被投票关闭。

    【讨论】:

    • 你好,艾尔先生。非常感谢您的回答,我们终于成功地在我们的游戏中添加自定义排行榜了:冒险时间play.google.com/store/apps/details?id=com.aaryavarta.up,但它显示来自全球排行榜的用户数量有限。我们现在有 5000 多个用户,但是当尝试为 20 个用户获取数据时,它只显示 4-5 个用户。
    • 嗨@AaryavartaTechnologies。抱歉,我已经有一段时间没有查看 Play 游戏了,想不起来太多了。但我想到的是,可能只有那么多玩家有相应的数据(分数)才能显示在排行榜中,那么我又可能错了。干杯!
    猜你喜欢
    • 2017-02-24
    • 1970-01-01
    • 2017-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多