Пример #1
0
    Carrot()
    {
        mCarrotCache = new CarrotCache();
        this.InstallDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(mCarrotCache.InstallDate);

        // Check to see if the official Facebook SDK is being used
        mFacebookDelegateType = Type.GetType("Facebook.FacebookDelegate,IFacebook");
        if(mFacebookDelegateType != null)
        {
            Type t = Type.GetType("FB");
            mOfficialFBSDKFeedMethod = t.GetMethod("Feed", BindingFlags.Static | BindingFlags.Public);

            t = Type.GetType("FBResult,IFacebook");
            mFBResultPropertyText = t.GetProperty("Text");
            mFBResultPropertyError = t.GetProperty("Error");
            mFacebookDelegateType = Type.GetType("Facebook.FacebookDelegate,IFacebook");

            if(mFacebookDelegateType != null &&
               mOfficialFBSDKFeedMethod != null &&
               mFBResultPropertyText != null &&
               mFBResultPropertyError != null &&
               mFacebookDelegateType != null)
            {
                mFacebookSDKType = FacebookSDKType.OfficialUnitySDK;
            }
        }
        #if UNITY_WEBPLAYER
        // If on Unity WebPlayer, some use the JavaScript SDK
        else
        {
            Application.ExternalEval("if(window.__carrotUnityInstance == null || window.__carrotUnityInstance == undefined) {" +
                                     "    window.__carrotUnityInstance = UnityObject2.instances[0];" +
                                     "}" +
                                     "window.__carrotUnityInstance.getUnity().SendMessage('CarrotGameObject', 'assignUnityObject2Instance', 'window.__carrotUnityInstance');"
            );
        }
        #endif
    }
Пример #2
0
 private void assignUnityObject2Instance(string message)
 {
     mFacebookSDKType = FacebookSDKType.JavaScriptSDK;
     mUnityObject2Instance = message;
 }