2017-10-06 13 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初期状態に戻っています。

関連する問題