Jump to content
Unity Insider Forum

Google Play Service keine Verbindung


Kojote

Recommended Posts

Hallo! :)
 

Ich sitze seit Tagen, um den Googly Play Service in meine App zu integrieren. Ich arbeite nach dem Tutorial, welches es zu Unity gibt, kein Scriptfehler, aber trotzdem lässt sich keine Verbindung herstellen.

Seht ihr einen Fehler?

using UnityEngine;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
using GooglePlayGames.BasicApi;
using GooglePlayGames.Android;
using UnityEngine.UI;
 
public class Google : MonoBehaviour {
 
    private static int googleLogin;
   
    private void Start() {
        googleLogin = 0;
        googleLogin = PlayerPrefs.GetInt("GoogleLogin", googleLogin);
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();
        if(googleLogin == 1) {
            PlayGamesPlatform.Instance.Authenticate((bool succes) => {
                if (succes) {
                    googleLogin = 1;
                } else {
                    googleLogin = 0;
                }
                PlayerPrefs.SetInt("GoogleLogin", googleLogin);
                PlayerPrefs.Save();
            });
        }
    }
 
    public void LogIn() {
        audioSourceSound.PlayOneShot(arraySFX[0]);
        PlayGamesPlatform.Instance.Authenticate((bool succes) => {
            if (succes) {
                googleLogin = 1;
                Debug.Log("HAPPY!");
            } else {
                googleLogin = 0;
                Debug.Log("ERROR!");
            }
            PlayerPrefs.SetInt("GoogleLogin", googleLogin);
            PlayerPrefs.Save();
        }, true);
    }
 
    public void LogOut() {
        if (Social.localUser.authenticated) {
            ((PlayGamesPlatform)Social.Active).SignOut();
            googleLogin = 0;
            PlayerPrefs.SetInt("GoogleLogin", googleLogin);
            PlayerPrefs.Save();
        }
    }
 
    public static void PunkteInBestenlisteEintragen(int punkteHighscore) {
        if (Social.localUser.authenticated) {
            Social.ReportScore(punkteHighscore, GPGSIds.leaderboard_highscore, (bool success) => {
            });
        }  
    }
 
    public void BestenlisteAnzeigen() {
        if (Social.localUser.authenticated) {
            ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(GPGSIds.leaderboard_highscore);
 
        }
    }
}

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 18 Stunden schrieb Kojote:

if(googleLogin == 1) { PlayGamesPlatform.Instance.Authenticate((bool succes) => { if (succes) { googleLogin = 1; } else { googleLogin = 0; } PlayerPrefs.SetInt("GoogleLogin", googleLogin); PlayerPrefs.Save(); })

wird LogIn() irgendwo mal aufgerufen? ich vermute mal googleLogin ist da immer 0 und er kommt gar nicht zum einloggen.

brauchst du dass mit dem ganzen playerprefs gedöhns?^^

 

So das minimum was man braucht 

using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine;

public class PlayGamesScript : MonoBehaviour {
		
    public static void SignIn()
    {
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();
        
        Social.localUser.Authenticate(succes => {
            if (succes)
                Debug.Log("gp eingeloggt!");
            else
                Debug.Log("gp login fail");
        });
    }
    
    public static void AddScoreToLeaderboard(string leaderboardId, long score)
    {
        Social.ReportScore(score, leaderboardId, succes => { });
    }

    public static void ShowLeaderboardsUI()
    {
        Social.ShowLeaderboardUI();        
    }  
}

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

  • 4 weeks later...

So, bin mal wieder dazu gekommen, etwas daran zu arbeiten. Selbst mit dieser Version funktioniert es nicht. :( Es ist echt zum verzweifeln!

EDIT: OK, Login geht, nur das Leaderborder wird nicht angezeigt. @GoldBaercheN - hast du dafür auch noch eine Idee? :)

EDIT 2: Hat sich geklärt, dass Problem lag nicht an meinem Script. Der Bug war im Google-Play-Games-Package und wurde mit Version 0.9.2 gefixt.

Link zu diesem Kommentar
Auf anderen Seiten teilen

Archiviert

Dieses Thema ist jetzt archiviert und für weitere Antworten gesperrt.

×
×
  • Neu erstellen...