2017-10-06 9 views
0

내가 개발 한 게임에 Google 플레이 서비스를 제공하려고합니다. 다음은 내 메인 화면에있는 스크립트입니다. 나는 전혀 응답을 얻지 못한다. 나는 모든 다른 SHA1 코드를 시도하고 무엇이 잘못되었는지 확신하지 못한다. 어떤 아이디어 ???Unity Google Play 서비스

using System.Collections; 
using System.Collections.Generic; 
using UnityEngine; 
using GooglePlayGames; 
using UnityEngine.UI; 
using GooglePlayGames.BasicApi; 
using UnityEngine.SocialPlatforms; 

public class GPS_Main : MonoBehaviour { 

    private bool IsConnectedToGoogleServices; 
    public Text SignIn; 

    private void Awake() 
    { 
     PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build(); 
     PlayGamesPlatform.InitializeInstance(config); 
     PlayGamesPlatform.Activate(); 
    } 

    // Use this for initialization 
    void Start() { 

     LogIn(); 

    } 

    // Update is called once per frame 
    void Update() { 

    } 

    void LogIn() 
    { 
     Social.localUser.Authenticate(success => { }); 

    } 

    public bool ConnectToGoogleServices() 
    { 
     if (!IsConnectedToGoogleServices) 
     { 
      Social.localUser.Authenticate((bool success) => 
      { 
       IsConnectedToGoogleServices = success; 
      }); 

     } 
     return IsConnectedToGoogleServices; 
     } 
    public static void ToAchievementUI() 
    { 
     if (Social.localUser.authenticated) 
     { 
      Social.ShowAchievementsUI(); 
     } 
     else 
     { 
      Debug.Log("Not authenticated"); 
     } 
    } 
} 

이것은 정말 짜증나는 사건이었습니다. 나는 많은 비디오와 책을 통해 올바른 문제를 찾아 왔습니다.

답변

0

문제가 발생하는 경우가 많습니다. 전화를 연결 한 다음 adb logcat을 사용하여 문제의 원인을 확인하는 것이 가장 좋은 방법입니다.

또한 내가 함수 ConnectToGoogleServices에 약간의 버그를 발견 한 :

public bool ConnectToGoogleServices() 
{ 
    if (!IsConnectedToGoogleServices) 
    { 
     Social.localUser.Authenticate((bool success) => 
     { 
      IsConnectedToGoogleServices = success; 
     }); 

    } 
    return IsConnectedToGoogleServices; 
} 

이 기능은 항상 IsConnectedToGoogleServices 초기 상태를 반환합니다.