我最近在我的游戏项目中安装了最新版本的facebook sdk 7.11.1 for unity,我没有任何问题导入了sdk但是每当我尝试运行该项目时,都会弹出这个错误!
这是错误日志
ReflectionTypeLoadException: The classes in the module cannot be loaded.
System.Reflection.Assembly.GetTypes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Assembly.cs:371)
Facebook.Unity.CodelessIAPAutoLog.FindTypeInAssemblies (System.String typeName, System.String nameSpace)
Facebook.Unity.CodelessIAPAutoLog.FindObjectsOfTypeByName (System.String typeName, System.String nameSpace)
Facebook.Unity.CodelessIAPAutoLog.addListenerToIAPButtons (System.Object listenerObject)
Facebook.Unity.Editor.EditorFacebookGameObject.OnAwake ()
Facebook.Unity.FacebookGameObject.Awake ()
UnityEngine.GameObject:AddComponent()
Facebook.Unity.ComponentFactory:GetComponent(IfNotExist)
Facebook.Unity.Editor.EditorFacebookLoader:get_FBGameObject()
Facebook.Unity.CompiledFacebookLoader:Start()
这是我使用的导致此错误的代码:
private void Awake()
{
if (!FB.IsInitialized)
{
FB.Init();
}
else
{
FB.ActivateApp();
}
}
public void LogIn()
{
FB.LogInWithReadPermissions(callback: OnLogIn);
}
void OnLogIn(ILoginResult result)
{
if (FB.IsLoggedIn)
{
AccessToken token = AccessToken.CurrentAccessToken;
}
}
public void Share()
{
FB.ShareLink(new Uri("google play link"), callback: Onshare);
}
private void Onshare(IShareResult result)
{
if (result.Cancelled || !string.IsNullOrEmpty(result.Error))
{
Debug.Log("ShareLink Error " + result.Error);
}
else if (!string.IsNullOrEmpty(result.PostId))
{
Debug.Log(result.PostId);
}
else
{
Debug.Log("Share Successful");
}
}
答案 0 :(得分:0)
似乎此错误仅出现在仍处于测试版的Unity 2018中,在2017.1 / 2017.2 / 2017.3版本上正常运行