2015-09-27 92 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);   
     } 

这个错误将被固定在未来的补丁..