非常奇怪的是在这方面投入了大量时间。所以问这里。
我正在使用此插件并按照https://github.com/playgameservices/play-games-plugin-for-unity
步骤操作我只想在发布模式下使用Google Play服务仅用于排行榜(我在alpha发布时使用)
以下是我在GPlay服务中使用Auth的代码:
void Awake(){
PlayerPrefs.SetInt("GameOverCount",0);
#if UNITY_ANDROID
Authenticate ();
#endif}
我已通过提供10位以上的客户端ID
配置了Gplay设置我已使用我正在使用的release.keystore的SHA1从Google APis生成OAuth客户端ID。 在DEveloper控制台的Gplay服务中:我发布了链接的应用程序,没有任何错误
public void Authenticate() {
if (Authenticated || mAuthenticating) {
Debug.LogWarning("Ignoring repeated call to Authenticate().");
return;
}
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.EnableSavedGames()
.Build();
PlayGamesPlatform.InitializeInstance(config);
// Activate the Play Games platform. This will make it the default
// implementation of Social.Active
PlayGamesPlatform.Activate();
// Set the default leaderboard for the leaderboards UI
((PlayGamesPlatform) Social.Active).SetDefaultLeaderboardForUI(leaderboardID_android);
// Sign in to Google Play Games
mAuthenticating = true;
Social.localUser.Authenticate((bool success) => {
mAuthenticating = false;
if (success) {
UnityAnalytics.CustomEvent("Auth Completed", new Dictionary<string, object>
{
{ "isAuthDone", true }
});
if(showScores){
Social.Active.ShowLeaderboardUI();
Debug.Log("should show leaderborad");
}
// if we signed in successfully, load data from cloud
Debug.Log("Login successful!");
} else {
// no need to show error message (error messages are shown automatically
// by plugin)
Debug.LogWarning("Failed to sign in with Google Play Games.");
UnityAnalytics.CustomEvent("Auth Failed", new Dictionary<string, object>
{
{ "isAuthDone", false }
});
}
});
}
#if UNITY_ANDROID
if (Authenticated) {
showScores = false;
((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboardID_android);
Social.ShowLeaderboardUI();
Debug.Log("should show leaderborad");
UnityAnalytics.CustomEvent("Authenticated and show android leaderboard", new Dictionary<string, object>
{
{ "isShowing", true }
});
}else{
showScores = true;
Authenticate();
}
#endif
接下来,我发布alpha并检查Android设备 - 我得到一个屏幕说连接谷歌玩游戏...连接进程,然后离开屏幕。 它似乎是认证和熄灭。但由于某种原因,它不会显示排行榜。我无法理解为什么会发生这种情况以及缺少什么。
在我的统一分析中,只有一次分数没有加载,我玩了20-30次:
在我的开发者控制台中,分数为空:
任何人都可以帮忙,我可以向有帮助/想要帮助的人提供更多细节....谢谢......