【问题标题】:Post score not taking place but leaderboard UI shows帖子得分未发生,但排行榜 UI 显示
【发布时间】:2019-05-08 10:32:40
【问题描述】:

我正在设置使用 GooglePlayGames api 实现的排行榜服务。我的身份验证和显示排行榜有效,但我将分数发布到排行榜的脚本不起作用。我已经环顾了很长时间,似乎发布分数的语法总是相同的,我也有。

    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。

关于为什么会这样的任何想法?排行榜 UI 显示,但没有得分。

【问题讨论】:

    标签: unity3d google-play-services


    【解决方案1】:

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

    在这种情况下你可以试试这个。

    puplic void leaderboardUI() {
        PostToLeaderboard(long newScore);
        // your code to show leaderboard
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-12
      • 2013-10-31
      • 1970-01-01
      • 2018-07-18
      • 2016-03-10
      • 2015-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多