首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未显示Post得分,但显示排行榜UI

未显示Post得分,但显示排行榜UI
EN

Stack Overflow用户
提问于 2019-05-08 18:32:41
回答 1查看 41关注 0票数 0

我正在设置一个排行榜服务,该服务是用GooglePlayGames应用编程接口实现的。我的身份验证和显示排行榜有效,但我将分数发布到排行榜的脚本不起作用。我已经看了很长一段时间了,似乎发布分数的语法总是一样的,我也有。

代码语言:javascript
复制
    void Start()
{
    AuthenticateUser();
}

void AuthenticateUser()
{
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.Activate();

    Social.localUser.Authenticate((bool success) =>
    {
        if (success == true)
        {
            Debug.Log("Logged in to Google play");
        }
        else
        {
            Debug.Log("There was an error login in to Google Play");
        }
    });
}

public static void PostToLeaderboard(long newScore)
{
    Social.ReportScore(10, GPGSIds.leaderboard_highscore, (bool success) =>
    {
        if (success == true)
        {
            Debug.Log("Score were sucessfully added to leaderboard");
        }
        else
        {
            Debug.Log("Unable to post score to leaderboard"); 
        }
    });
}

这是我的代码,用于验证并将分数发布到排行榜。我在代码Social.ReportScore函数调用中硬编码了10。

你知道为什么会这样吗?leaderboardUI出现了,但没有分数。

EN

回答 1

Stack Overflow用户

发布于 2019-05-22 01:48:56

在调用leaderboardUI方法之前,请确保运行PostToLeaderboard(long newScore)方法来更新排行榜。

在这里,在这种情况下,您可以尝试这个。

代码语言:javascript
复制
puplic void leaderboardUI() {
    PostToLeaderboard(long newScore);
    // your code to show leaderboard
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56038699

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档