Using FaceBook SDK on Unity 4.6

If you are using the FaceBook SDK on the new beta you will get the following error on calling FB.Init()

Could not securely load assembly from https://integrated-plugin-canvas-rsrc.fbsbx.com/rsrc/unity/lib/sdk_5.1/CanvasFacebook.dll
UnityEngine.Debug:LogError(Object)
FbDebug:Error(String)
<LoadFacebookClass>c__Iterator9:MoveNext() (at Assets/Generic Scripts/Facebook/Scripts/FB.cs:396)

Solution below

Open FB.cs

Go to line 380. Find the following code:

#if UNITY_4_5
            var authTokenWww = new WWW(IntegratedPluginCanvasLocation.KeyUrl);
            yield return authTokenWww;
            if (authTokenWww.error != null)
            {
                FbDebug.Error("Cannot load from " + IntegratedPluginCanvasLocation.KeyUrl + ": " + authTokenWww.error);
                authTokenWww.Dispose();
                yield break;
            }
            var assembly = Security.LoadAndVerifyAssembly(www.bytes, authTokenWww.text);
#else
            var assembly = Security.LoadAndVerifyAssembly(www.bytes);
#endif

Change it as follows (taking out the #if Unity_4_5 and everything in the else block)

        var authTokenWww = new WWW(IntegratedPluginCanvasLocation.KeyUrl);
        yield return authTokenWww;
        if (authTokenWww.error != null)
        {
            FbDebug.Error("Cannot load from " + IntegratedPluginCanvasLocation.KeyUrl + ": " + authTokenWww.error);
            authTokenWww.Dispose();
            yield break;
        }
        var assembly = Security.LoadAndVerifyAssembly(www.bytes, authTokenWww.text);

I’m sure Facebook will catch it in a future version of the SDK

For Unity 5.1 users and Facebook 6.2.2. Expanding condition in FB.cs in line 411 with || UNITY_5_1 helped me.

#if UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5