与 playfab 统一的排行榜

问题描述 投票:0回答:1

在我的例子中,用户使用用户名和密码登录,我想知道如何让排行榜留下该用户名而不是用户ID,有人可以帮助我吗?

我看过使用显示名称的视频,但没有办法直接获取用户名,仅此而已?我看过使用显示名称的视频,但没有办法直接获取用户名

unity-game-engine leaderboard playfab
1个回答
0
投票

当然,有一种方法可以通过在排行榜请求中启用该选项来从 PlayFab 获取玩家 DisplayName。 由于您没有共享任何代码示例,我假设您没有启用该选项。从 PlayFab 获取排行榜的示例,其中包括玩家 DisplayName

PlayFabClientAPI.GetLeaderboard(new GetLeaderboardRequest()
        {
            StartPosition = 0, // Starting position on leaderboard
            StatisticName = "Trophies", // your statistic name
            ProfileConstraints =
            new PlayerProfileViewConstraints()
            {
                ShowDisplayName = true // This option will allow you to get player DisplayName in every leaderboard entry in the returned list
            }
        }, (result)=>
        {
            // result.Leaderboard is List<PlayerLeaderboardEntry>
            for(int entryIndex = 0; result.Leaderboard.Count; entryIndex++;)
            {
               Debug.Log($"{result.Leaderboard[entryIndex].Position}-  Name: {result.Leaderboard[entryIndex].DisplayName}");
            }
        }, (error)=>{});

参考 PlayFab Leaderboard 文档,我建议您仔细阅读它,您可以在 GetLeaderboard 请求中包含很多选项

© www.soinside.com 2019 - 2024. All rights reserved.