2015-09-27 56 views
-1

嗨,大家好我是一個遊戲正在與Facebook登錄,但是我保持STUK在此錯誤初始化失敗的Facebook SDK Unity5.2的Facebook SDK 7個

初始化失敗了Facebook SDK

這裏我的代碼

using UnityEngine; 
using System.Collections; 
using System.Collections.Generic; 
using Facebook.Unity; 

public class FBholder : MonoBehaviour { 

void Awake() 
{ 
    if (!FB.IsInitialized) { 
     // Initialize the Facebook SDK 
     FB.Init(InitCallback, OnHideUnity); 


    } else { 
     // Already initialized, signal an app activation App Event 
     FB.ActivateApp(); 
    } 
} 

private void InitCallback() 
{ 
    if (FB.IsInitialized) { 
     // Signal an app activation App Event 
     FB.ActivateApp(); 
     // Continue with Facebook SDK 

    } else { 
     Debug.Log("Failed to Initialize the Facebook SDK"); 
    } 

    FB.ActivateApp(); 
    var perms = new List<string>(){"public_profile", "email", "user_friends"}; 
    FB.LogInWithReadPermissions(perms, AuthCallback); 
} 

private void OnHideUnity (bool isGameShown) 
{ 
    if (!isGameShown) { 
     // Pause the game - we will need to hide 
     Time.timeScale = 0; 
    } else { 
     // Resume the game - we're getting focus again 
     Time.timeScale = 1; 
    } 
} 

private void AuthCallback (ILoginResult result) { 
    if (FB.IsLoggedIn) { 
     // AccessToken class will have session details 
     var aToken = Facebook.Unity.AccessToken.CurrentAccessToken; 
     // Print current access token's User ID 
     Debug.Log(aToken.UserId); 
     // Print current access token's granted permissions 
     foreach (string perm in aToken.Permissions) { 
      Debug.Log(perm); 
     } 
    } else { 
     Debug.Log("User cancelled login"); 
    } 
} 

} 

我已經加了我的應用程序ID在Facebook的設置團結

我用這個文檔 https://developers.facebook.com/docs/unity/examples

回答

2

查找FacebookGameObject.cs ..然後替換此:

public void OnInitComplete(string message) 
     { 
      this.Facebook.OnInitComplete(message); 
      this.Initialized = true;   
     } 

與此:

public void OnInitComplete(string message) 
     { 
      this.Initialized = true; 
      this.Facebook.OnInitComplete(message);   
     } 

這個錯誤將被固定在未來的補丁..