我正在Unity中开发一个Android游戏,需要实现排行榜。因此,我安装了最新的Google Play游戏插件。在Google Play控制台中创建了排行榜。从Windows> Google Play游戏>设置> Android设置> 资源定义中的Play控制台复制并粘贴Android资源。 然后,我创建了一个名为“ PlayGamesScript”的C#脚本,并将其附加到场景中的游戏对象上。然后,我通过所需的脚本传递了LeaderboardID和得分,并从页首横幅按钮中调用了ShowLeaderboardsUI()。没有错误。但是在构建游戏之后,当我在设备上玩游戏时,它没有显示Google Play游戏登录选项。 以下是我的PlayGamesScript代码:
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine;
using UnityEngine.SocialPlatforms;
public class PlayGamesScript : MonoBehaviour {
void Start () {
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
SignIn();
}
void SignIn()
{
Social.localUser.Authenticate(success => { });
}
#region Leaderboards
public static void AddScoreToLeaderboard(string leaderboardId, long score)
{
Social.ReportScore(score, leaderboardId, success => {});
}
public static void ShowLeaderboardsUI()
{
Social.ShowLeaderboardUI();
}
#endregion /Leaderboards
}
请帮助我解决此问题。预先感谢!