Android中的排行榜

时间:2018-02-27 12:37:00

标签: android unity3d google-play-services

面对Google正确记录所有内容的问题,但它并非徒劳,虽然它会进入Google Play帐户,之后会稍微考虑并将其发送回游戏。

也许代码中的某些内容是错误的。

private string leaderboard = "CgkI9pfnzM8FEAIQAQ";

void Start()
{
    PlayGamesPlatform.Activate();
    Social.localUser.Authenticate((bool success) => {
        if(success) 
        {
            Debug.Log("You have successefully loged in");
        } 
        else
        {
            Debug.Log("Login failded");
        }
    });
}

LeaderboardOn()
{
    ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboard);
}

Hightscore()
{
    if(score>highscore)
    {
        PlayerPrefs.SetInt("Highscore", score);
        gameOverHighScoreText.GetComponent<Text>().text ="HIGHSCORE:"+score.ToString();
        Social.ReportScore(score, leaderboard, (bool success) => {
            if (success) print("Successefully added to Leaderboard");
        });
    }
}

1 个答案:

答案 0 :(得分:1)

你好МикитаРєпін
您可以通过执行以下操作激活PlayGamesPlatform:

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

其他一切似乎都没问题,唯一的问题就是

  • LeaderboardOn()应为void LeaderboardOn()
  • Highstcore()应为void Highstcore()