private void secondColumnAdditionalButtonsGUI()
    {
        if (GUILayout.Button("Custom Graph Request"))
        {
            Facebook.instance.graphRequest("platform/posts", HTTPVerb.GET, completionHandler);
        }


        if (GUILayout.Button("Custom REST Request"))
        {
            var hash = new Hashtable();
            hash.Add("query", "SELECT uid,name FROM user WHERE uid=4");
            FacebookBinding.restRequest("fql.query", "POST", hash);
        }


        /* Note: it is not recommended to include your app secret in your app binary. Getting an app access token
         * should occur on your own web server to remain secure
         * if( GUILayout.Button( "Get App Access Token" ) )
         * {
         *      //Facebook.instance.getAppAccessToken( "YOUR_APP_ID", "YOUR_APP_SECRET", token =>
         *      {
         *              Debug.Log( "app access token retrieved: " + token );
         *      });
         * }
         */


        if (GUILayout.Button("Post Score"))
        {
            if (userId == null)
            {
                Debug.Log("First call the 'me' graph request to gather the user's userId");
                return;
            }

            Facebook.instance.postScore(userId, 250, didSucceed =>
            {
                Debug.Log("score post suceeded? " + didSucceed);
            });
        }


        if (GUILayout.Button("Get Scores"))
        {
            if (userId == null)
            {
                Debug.Log("First call the 'me' graph request to gather the user's userId");
                return;
            }

            Facebook.instance.getScores(userId, completionHandler);
        }


        if (GUILayout.Button("Get App Launch Url"))
        {
            Debug.Log("app launch url: " + FacebookBinding.getAppLaunchUrl());
        }
    }
Beispiel #2
0
    void Start()
    {
        // dump custom data to log after a request completes
        FacebookManager.graphRequestCompletedEvent += result =>
        {
            Prime31.Utils.logObject(result);
        };

        // when the session opens or a reauth occurs we check the permissions to see if we can publish
        FacebookManager.sessionOpenedEvent += () =>
        {
            _hasPublishPermission = FacebookBinding.getSessionPermissions().Contains("publish_stream");
            _hasPublishActions    = FacebookBinding.getSessionPermissions().Contains("publish_actions");
        };

        FacebookManager.reauthorizationSucceededEvent += () =>
        {
            _hasPublishPermission = FacebookBinding.getSessionPermissions().Contains("publish_stream");
            _hasPublishActions    = FacebookBinding.getSessionPermissions().Contains("publish_actions");
        };

        // grab a screenshot for later use
        Application.CaptureScreenshot(screenshotFilename);

        // this is iOS 6 only!
        _canUserUseFacebookComposer = FacebookBinding.canUserUseFacebookComposer();

        // optionally enable logging of all requests that go through the Facebook class
        //Facebook.instance.debugRequests = true;
    }
Beispiel #3
0
 void Awake()
 {
     FacebookBinding.Init(facebookAppID);
     loader = GameObject.Find("Loader").GetComponent <Loader> ();
     loader.enableLoader();
     checkInternet();
 }
Beispiel #4
0
    void OnGUI()
    {
        GUI.skin = skin;

        GUI.DrawTexture(UtilResize.ResizeGUI(new Rect(0, 0, 320, 480)), backgroundImg);

        GUI.enabled = (statusMsg == "");
        //Login Controls
        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 10, 220, 20)), "eMail", "LabelBold");
        email = GUI.TextField(UtilResize.ResizeGUI(new Rect(80, 30, 220, 40)), email, 100);

        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 75, 220, 20)), "Password", "LabelBold");
        password = GUI.PasswordField(UtilResize.ResizeGUI(new Rect(80, 100, 220, 40)), password, '*');


        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 150, 220, 50)), "Login"))
        {
            GamedoniaUsers.LoginUserWithEmail(email.ToLower(), password, OnLogin);
        }

        GUIStyle fbButton = GUI.skin.GetStyle("ButtonFacebook");

        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 205, 220, 50)), "Facebook", fbButton))
        {
            statusMsg = "Initiating Facebook session...";
            FacebookBinding.OpenSessionWithReadPermissions(READ_PERMISSIONS, OnFacebookOpenSession);
        }

        GUIStyle separator = GUI.skin.GetStyle("separator");

        GUI.Box(UtilResize.ResizeGUI(new Rect(80, 277, 220, 1)), "", separator);

        //Sign Up
        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 300, 220, 50)), "Sign Up"))
        {
            //print ("you clicked the text button");
            Application.LoadLevel("CreateAccountScene");
        }

        //Password Recovery
        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 355, 220, 50)), "Remember Password"))
        {
            Application.LoadLevel("ResetPasswordScene");
        }

        if (errorMsg != "")
        {
            GUI.Box(new Rect((Screen.width - (UtilResize.resMultiplier() * 260)), (Screen.height - (UtilResize.resMultiplier() * 50)), (UtilResize.resMultiplier() * 260), (UtilResize.resMultiplier() * 50)), errorMsg);
            if (GUI.Button(new Rect(Screen.width - 20, Screen.height - UtilResize.resMultiplier() * 45, 16, 16), "x", "ButtonSmall"))
            {
                errorMsg = "";
            }
        }

        GUI.enabled = true;
        if (statusMsg != "")
        {
            GUI.Box(UtilResize.ResizeGUI(new Rect(80, 240 - 40, 220, 40)), statusMsg);
        }
    }
Beispiel #5
0
    /** FACEBOOK LOGIN **/

    public void LoginWithFacebook()
    {
        if (!Application.isEditor)
        {
            statusMsg = "Initiating Facebook session...";
            FacebookBinding.OpenSessionWithReadPermissions(READ_PERMISSIONS, OnFacebookOpenSession);
        }
        else
        {
            errorMsg = "Facebook won't work on Unity Editor, try it on a device.";
        }
    }
Beispiel #6
0
 void OnFacebookOpenSession(bool success, bool userCancelled, string message)
 {
     if (success)
     {
         statusMsg = "Recovering Facebook profile...";
         FacebookBinding.RequestWithGraphPath("/me", null, "GET", OnFacebookMe);
     }
     else
     {
         errorMsg = "Unable to open session with Facebook";
     }
 }
 void sessionOpenedEvent()
 {
     // do we need publish permissions?
     if (requiresPublishPermissions && !FacebookBinding.getSessionPermissions().Contains("publish_stream"))
     {
         FacebookBinding.reauthorizeWithPublishPermissions(new string[] { "publish_actions", "publish_stream" }, FacebookSessionDefaultAudience.Everyone);
     }
     else
     {
         afterAuthAction();
         cleanup();
     }
 }
Beispiel #8
0
    private void OnFacebookMe(IDictionary data)
    {
        statusMsg  = "Initiating Gamedonia session...";
        fbUserId   = data ["id"] as string;
        fbUserName = data ["name"] as string;
        Debug.Log("AccessToken: " + FacebookBinding.GetAccessToken() + " fbuid: " + fbUserId);


        Dictionary <string, object> facebookCredentials = new Dictionary <string, object> ();

        facebookCredentials.Add("fb_uid", fbUserId);
        facebookCredentials.Add("fb_access_token", FacebookBinding.GetAccessToken());

        GamedoniaUsers.Authenticate(GamedoniaBackend.CredentialsType.FACEBOOK, facebookCredentials, OnFacebookLogin);
    }
    void Start()
    {
        // Dump custom data to log after a request completes
        FacebookManager.graphRequestCompletedEvent += result =>
        {
            Prime31.Utils.logObject(result);
        };

        // grab a screenshot for later use
        Application.CaptureScreenshot(screenshotFilename);

        // this is iOS 6 only!
        canUserUseFacebookComposer = FacebookBinding.canUserUseFacebookComposer();

        // optionally enable logging of all requests that go through the Facebook class
        //Facebook.instance.debugRequests = true;
    }
Beispiel #10
0
 // Reauthorizes with the requested read permissions
 public void ReauthorizeWithReadPermissions(string[] permissions)
 {
     FacebookBinding.reauthorizeWithReadPermissions(permissions);
 }
Beispiel #11
0
 // Opens the Facebook single sign on login in Safari, the official Facebook app or uses iOS 6 Accounts if available
 public void Login()
 {
     FacebookBinding.login();
 }
Beispiel #12
0
 // Logs the user out and invalidates the token
 public void Logout()
 {
     FacebookBinding.logout();
 }
Beispiel #13
0
 // Enables frictionless requests
 public void EnableFrictionlessRequests()
 {
     FacebookBinding.enableFrictionlessRequests();
 }
Beispiel #14
0
    //=============================================================================

    void Start()
    {
        if (m_bVerbose)
        {
            Debug.Log("AchievementsManager: Start");
        }

        if (m_bInitialised == false)
        {
            m_bInitialised                = true;
            m_bIsLoggedIn                 = false;
            m_Instance                    = this;
            m_bIsUploadingAchievement     = false;
            m_UploadingAchievementTimeout = 10.0f;
            m_UploadingAchievementID      = -1;

            m_ManagerState = eManagerState.Idle;

            if (m_bVerbose)
            {
                Debug.Log("AchievementsManager: Init");
            }
        }

        // Connect to Game Center / Google Play
                #if UNITY_IPHONE
        GameCenterManager.playerAuthenticatedEvent        += GCOnPlayerAuthenticated;
        GameCenterManager.playerFailedToAuthenticateEvent += GCOnPlayerFailedToAuthenticate;
        GameCenterManager.reportAchievementFailedEvent    += GCOnReportAchievementFailed;
        GameCenterManager.reportAchievementFinishedEvent  += GCOnReportAchievementFinished;
        GameCenterManager.reportScoreFailedEvent          += GCOnReportScoreFailed;
        GameCenterManager.reportScoreFinishedEvent        += GCOnReportScoreFinished;

        // Auto login if we already logged in a previous time
        //if( PlayerPrefs.GetInt( "GCGPAutoLogin" , 0 ) > 0 )
        {
            Login();
        }
                #endif

                #if UNITY_ANDROID
        GPGManager.authenticationSucceededEvent    += GPOnPlayerAuthenticated;
        GPGManager.authenticationFailedEvent       += GPOnPlayerFailedToAuthenticate;
        GPGManager.unlockAchievementFailedEvent    += GPOnReportAchievementFailed;
        GPGManager.unlockAchievementSucceededEvent += GPOnReportAchievementFinished;
        GPGManager.submitScoreFailedEvent          += GPOnReportScoreFailed;
        GPGManager.submitScoreSucceededEvent       += GPOnReportScoreFinished;

        // Auto login if we already logged in a previous time
        //if( PlayerPrefs.GetInt( "GCGPAutoLogin" , 0 ) > 0 )
        {
            Login();
        }
                #endif

        // Playtomic init (scoreboards)
        Playtomic.Initialize("4297CC23E31BC29545FC2A9577AD4", "14A8D1497B7B68DBF43D97128CB88", "http://shreditscoreboard.herokuapp.com/");

        // Connect to Facebook/Twitter
                #if UNITY_IPHONE || UNITY_ANDROID
        FacebookCombo.init();
        TwitterCombo.init("GPC3ImeHkYHf0Bdhr9gNC39SW", "dty3PjzDLQTnlQ9jjqMJUM2oy4apJhqtPpaFCX0oVcLvTw2kPg");
                #endif

                #if UNITY_IPHONE && !UNITY_EDITOR
        FacebookBinding.setSessionLoginBehavior(FacebookSessionLoginBehavior.ForcingWebView);
                #endif

        // For debug builds register a random player
        RandomiseName();
    }
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize Facebook"))
        {
            FacebookBinding.init();
        }


        if (GUILayout.Button("Login"))
        {
            // Note: requesting publish permissions here will result in a crash. Only read permissions are permitted.
            var permissions = new string[] { "user_games_activity" };
            FacebookBinding.loginWithReadPermissions(permissions);
        }


        if (GUILayout.Button("Reauth with Publish Permissions"))
        {
            var permissions = new string[] { "publish_actions", "publish_stream" };
            FacebookBinding.reauthorizeWithPublishPermissions(permissions, FacebookSessionDefaultAudience.OnlyMe);
        }


        if (GUILayout.Button("Logout"))
        {
            FacebookBinding.logout();
        }


        if (GUILayout.Button("Is Session Valid?"))
        {
            bool isLoggedIn = FacebookBinding.isSessionValid();
            Debug.Log("Facebook is session valid: " + isLoggedIn);
        }


        if (GUILayout.Button("Get Access Token"))
        {
            var token = FacebookBinding.getAccessToken();
            Debug.Log("access token: " + token);
        }


        if (GUILayout.Button("Get Granted Permissions"))
        {
            var permissions = FacebookBinding.getSessionPermissions();
            foreach (var perm in permissions)
            {
                Debug.Log(perm);
            }
        }


        endColumn(true);


        // toggle to show two different sets of buttons
        if (toggleButtonState("Toggle Alternate Buttons"))
        {
            secondColumnButtonsGUI();
        }
        else
        {
            secondColumnAdditionalButtonsGUI();
        }
        toggleButton("Toggle Alternate Buttons", "Toggle Buttons");

        endColumn(false);


        if (bottomRightButton("Twitter..."))
        {
            Application.LoadLevel("TwitterTestScene");
        }
    }
Beispiel #16
0
 // Sets the login behavior. Must be called before any login calls! Understand what the login behaviors are and how they work before using this!
 public void GetUsername(FacebookSessionLoginBehavior loginBehavior)
 {
     FacebookBinding.setSessionLoginBehavior(loginBehavior);
 }
Beispiel #17
0
 // Checks to see if the current session is valid
 public bool IsLoggedIn()
 {
     return(FacebookBinding.isSessionValid());
 }
Beispiel #18
0
 // iOS 6 only. Renews the credentials that iOS stores for any native Facebook accounts. You can safely call this at app launch or when logging a user out.
 public void RenewAllAccountsCredentials()
 {
     FacebookBinding.renewCredentialsForAllFacebookAccounts();
 }
Beispiel #19
0
 // Allows you to use any available Facebook Graph API method
 public void UseGraphApiMethod(string graphPath, string httpMethod, Hashtable keyValueHash)
 {
     FacebookBinding.graphRequest(graphPath, httpMethod, keyValueHash);
 }
Beispiel #20
0
 void Awake()
 {
     FacebookBinding.Init(FB_APP_ID);
 }
Beispiel #21
0
 // Shows the native authorization dialog (iOS 6), opens the Facebook single sign on login in Safari or the official Facebook app with the requested read (not publish!) permissions
 public void LoginWithReadPermissions(string[] permissions, string urlSchemeSuffix)
 {
     FacebookBinding.loginWithReadPermissions(permissions, urlSchemeSuffix);
 }
Beispiel #22
0
 public void LoginWithReadPermissions(string[] permissions)
 {
     FacebookBinding.loginWithReadPermissions(permissions);
 }
Beispiel #23
0
 // Gets the permissions granted to the current access token
 public List <object> GetSessionPermissions()
 {
     return(FacebookBinding.getSessionPermissions());
 }
Beispiel #24
0
 // Gets the current access token
 public string GetAccessToken()
 {
     return(FacebookBinding.getAccessToken());
 }
 public void start()
 {
     FacebookBinding.login();
 }
    void OnGUI()
    {
        //write your GUI elements for 1280x720
        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(Screen.width / targetWidth, Screen.height / targetHeight, 1));

        KongregateAPI kongregate = KongregateAPI.GetAPI();

        // isReady() is true if we are on iOS platform and the API is initalized properly
        if (kongregate.IsReady())
        {
#if UNITY_STANDALONE
            if (GUI.Button(new Rect(targetWidth / 2 - 170 - 5, 10, 80, 40), "Reset Data"))
            {
                Kongregate.DataStore dataStore = Kongregate.DataStore.Get("analytics");
                string playerId = dataStore.GetString("player_id", "");
                Debug.Log("PlayerID was: " + playerId);
                dataStore.DeleteAll();
                if (!string.IsNullOrEmpty(playerId))
                {
                    dataStore.SetString("player_id", playerId);
                }
            }
#endif

            // add a simple button to demonstrate hidding and showing the K button
            if (GUI.Button(new Rect(targetWidth / 2 - 80 - 5, 10, 80, 40), "Toggle K"))
            {
                if (kongregate.Mobile.ButtonIsHidden())
                {
                    kongregate.Mobile.ButtonShow();
                }
                else
                {
                    kongregate.Mobile.ButtonHide();
                }
            }

            // add a simple button to demonstrate submitting stats
            if (GUI.Button(new Rect(targetWidth / 2 + 5, 10, 80, 40), "Submit Win"))
            {
                kongregate.Stats.Submit("Wins", 1);
            }

            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "type", "Gold Pack" },
                { "discount_percent", 12.5 },
                { "context_of_offer", "StoreFront" }
            };

            if (mPurchaseReady)
            {
                if (GUI.Button(new Rect(targetWidth / 2 - 170 - 5, 60, 80, 40), "Purchase"))
                {
                    mPurchaseReady = false; // disable button when clicked
#if UNITY_IPHONE && PRIME31_STOREKIT
                    kongregate.Analytics.StartPurchase("com.kongregate.mobile.games.angryBots.t05_coins", 1, fields);
                    StoreKitBinding.purchaseProduct("com.kongregate.mobile.games.angryBots.t05_coins", 1);
#elif UNITY_ANDROID && PRIME31_STOREKIT
                    kongregate.Analytics.StartPurchase("com.kongregate.android.games.angrybots.t03_hard", 1, fields);
                    GoogleIAB.purchaseProduct("com.kongregate.android.games.angrybots.t03_hard");
#elif UNITY_WEBPLAYER || UNITY_WEBGL
                    kongregate.Analytics.StartPurchase("com.kongregate.web.angrybots.t05_hard", 1, fields);

                    // Use the Javascript API to initiate the purchase. Notice in this flow we call finishPurchase via
                    // the Javascript API after the purchase is completed by serializing the game fields needed. You
                    // could also save the game fields into a variable in your Unity script and then call
                    // kongregate.Analytics.FinishPurchase(...) in the Unity callback as well.
                    Application.ExternalEval(string.Format(
                                                 @"kongregate.mtx.purchaseItems(['com.kongregate.web.angrybots.t05_hard'], function(result){{
                var status = result.success ? 'SUCCESS' : 'FAIL';
                var data = result.success ? '{0}' : '{1}';
                kongregate.analytics.finishPurchase(status, result.purchase_id, data);

                // Fire the callback in the Unity code
                kongregateUnitySupport.getUnityObject().SendMessage('Kongregate', 'OnKredPurchaseResult', status);
            }});"
                                                 , Kongregate.Analytics.toAnalyticEventJSON(getPurchaseFields()), Kongregate.Analytics.toAnalyticEventJSON(fields)));
#elif UNITY_STANDALONE
                    kongregate.Analytics.StartPurchase("com.kongregate.mobile.games.angryBots.t05_hard", 1, fields);
#endif
                }

#if UNITY_IPHONE && PRIME31_STOREKIT
                if (GUI.Button(new Rect(targetWidth / 2 + 5, 60, 80, 40), "Restore"))
                {
                    StoreKitBinding.restoreCompletedTransactions();
                }
#endif
                if (mRecentPurchase)
                {
                    GUI.Box(new Rect(targetWidth / 2 - 70, targetHeight / 2 - 30, 140, 60), "Purchase Successful!");
                    if (GUI.Button(new Rect(targetWidth / 2 - 20, targetHeight / 2, 40, 20), "OK"))
                    {
                        mRecentPurchase = false;
                    }
                }
            }

#if UNITY_STANDALONE
            if (!mPurchaseReady)
            {
                if (GUI.Button(new Rect(targetWidth / 2 - 170 - 5, 60, 80, 40), "Finish"))
                {
                    kongregate.Analytics.FinishPurchase("SUCCESS", null, getPurchaseFields());
                    mPurchaseReady = true;
                }

                if (GUI.Button(new Rect(targetWidth / 2 - 80 - 5, 60, 80, 40), "Cancel"))
                {
                    kongregate.Analytics.FinishPurchase("FAIL", null, fields);
                    mPurchaseReady = true;
                }
            }
#endif

            // add text fields to demonstrate submitting generic stat types
            GUI.Label(new Rect(targetWidth / 2 + 95, 10, 50, 20), "Stat:");
            mCustomStatId = GUI.TextField(new Rect(targetWidth / 2 + 140, 10, 80, 20), mCustomStatId);
            GUI.Label(new Rect(targetWidth / 2 + 95, 35, 50, 20), "Value:");
            mCustomStatValue = GUI.TextField(new Rect(targetWidth / 2 + 140, 35, 80, 20), mCustomStatValue);
            if (GUI.Button(new Rect(targetWidth / 2 + 230, 10, 80, 40), "Submit"))
            {
                long value = 0;
                if (long.TryParse(mCustomStatValue, out value))
                {
                    kongregate.Stats.Submit(mCustomStatId, long.Parse(mCustomStatValue));
                }
            }

            if (GUI.Button(new Rect(targetWidth / 2 + 430, 10, 100, 40), "Inventory"))
            {
                mInventory = false;
                kongregate.Mtx.RequestUserItemList();
            }

            GUI.Box(new Rect(5, 105, 200, 60), "");

            if (mInventory)
            {
                GUI.Label(new Rect(10, 110, 200, 20), "Has AWESOME GUN: " + mHasGun);
            }
            else
            {
                GUI.Label(new Rect(10, 110, 200, 20), "Requesting inventory...");
            }

            if (mUsername != null)
            {
                GUI.Label(new Rect(10, 125, 200, 20), "Username: "******", id: " + mUserId);
                GUI.Label(new Rect(10, 140, 200, 20), "KongPlus: " + mHasKongPlus);
            }

            if (GUI.Button(new Rect(targetWidth / 2 + 535, 10, 100, 40), "FBPost"))
            {
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "link", "http://www.kongregate.com" },
                    { "name", "AngryBots" },
                    { "caption", "Testing 123" },
                    { "description", "Test Post" }
                };
#if UNITY_ANDROID && PRIME31_SOCIAL
                FacebookAndroid.showFacebookShareDialog(parameters);
#elif UNITY_IPHONE && PRIME31_SOCIAL
                FacebookBinding.showFacebookShareDialog(parameters);
#endif
            }

            if (GUI.Button(new Rect(targetWidth / 2 + 535, 60, 100, 40), "More Games"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_MORE_GAMES);
            }
            if (GUI.Button(new Rect(targetWidth / 2 + 535, 110, 100, 40), "High Scores"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_HIGH_SCORES);
            }
            if (GUI.Button(new Rect(targetWidth / 2 + 535, 160, 100, 40), "Support"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_SUPPORT);
            }
            if (GUI.Button(new Rect(targetWidth / 2 + 535, 210, 100, 40), "Forums"))
            {
                kongregate.Mobile.OpenKongregateWindow(Kongregate.Mobile.TARGET_FORUMS);
            }

            // add a simple button to demonstrate submitting analytics
            mPlayTimer = new System.Diagnostics.Stopwatch();
            mPlayTimer.Start();
            if (GUI.Button(new Rect(targetWidth / 2 + 330, 10, 80, 40), "Play Ends"))
            {
                DemoAddAnalyticsEvent();
            }

            // if our button is not hidden, we need to draw it
            Rect kButtonRect = new Rect(10, 10, 100, 100);
            if (kongregate.Mobile.ButtonIsNativeRendering())
            {
                //nothing to do, rendering is handled in native SDK
                // NOTE: notification count is not supported by native rendering
            }
            else if (!kongregate.Mobile.ButtonIsHidden())
            {
                // draw the K button
                if (GUI.Button(kButtonRect, mKongButtonTexture))
                {
                    Debug.Log("You clicked the Kong button!");
                    kongregate.Mobile.OpenKongregateWindow();
                }
                if (mNotificationCountTexture)
                {
                    GUI.Label(new Rect(90, 20, 50, 50), mNotificationCountTexture);
                }
            }

            // add buttons for the deep links
            Rect deepLinkButtonsRect = new Rect(kButtonRect.x, kButtonRect.y + kButtonRect.height + 60, 200, 400);
            Rect targetIdLabelRect   = new Rect(deepLinkButtonsRect.x, deepLinkButtonsRect.y + deepLinkButtonsRect.height + 20, 100, 50);
            Rect targetIdTextRect    = new Rect(targetIdLabelRect.x + targetIdLabelRect.width, targetIdLabelRect.y, 100, 50);
            GUI.Label(targetIdLabelRect, "TargetId:");
            mTargetIdText = GUI.TextField(targetIdTextRect, mTargetIdText);
            int deepLinkClick = GUI.SelectionGrid(deepLinkButtonsRect, -1, mDeepLinkTargets, 2);
            if (deepLinkClick >= 0)
            {
                KongregateAPI.GetAPI().Mobile.OpenKongregateWindow(mDeepLinkTargets[deepLinkClick], mTargetIdText);
            }
        } // IsReady
    }     // OnGUI
Beispiel #27
0
    private void secondColumnButtonsGUI()
    {
        // only show posting actions if we have permission to do them
        if (_hasPublishPermission)
        {
            if (GUILayout.Button("Post Image"))
            {
                var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
                if (!System.IO.File.Exists(pathToImage))
                {
                    Debug.LogError("there is no screenshot avaialable at path: " + pathToImage);
                    return;
                }

                var bytes = System.IO.File.ReadAllBytes(pathToImage);
                Facebook.instance.postImage(bytes, "im an image posted from iOS", completionHandler);
            }


            if (GUILayout.Button("Post Message"))
            {
                Facebook.instance.postMessage("im posting this from Unity: " + Time.deltaTime, completionHandler);
            }


            if (GUILayout.Button("Post Message & Extras"))
            {
                Facebook.instance.postMessageWithLinkAndLinkToImage("link post from Unity: " + Time.deltaTime, "http://prime31.com", "Prime31 Studios", "http://prime31.com/assets/images/prime31logo.png", "Prime31 Logo", completionHandler);
            }
        }
        else
        {
            GUILayout.Label("Reauthorize with publish_stream permissions to show posting buttons");
        }


        if (GUILayout.Button("Graph Request (me)"))
        {
            Facebook.instance.getMe((error, result) =>
            {
                // if we have an error we dont proceed any further
                if (error != null)
                {
                    return;
                }

                if (result == null)
                {
                    return;
                }

                // grab the userId and persist it for later use
                _userId = result.id;

                Debug.Log("me Graph Request finished: ");
                Debug.Log(result);
            });
        }


        if (GUILayout.Button("Show stream.publish Dialog"))
        {
            // parameters are optional. See Facebook's documentation for all the dialogs and parameters that they support
            var parameters = new Dictionary <string, string>
            {
                { "link", "http://prime31.com" },
                { "name", "link name goes here" },
                { "picture", "http://prime31.com/assets/images/prime31logo.png" },
                { "caption", "the caption for the image is here" }
            };
            FacebookBinding.showDialog("stream.publish", parameters);
        }


        if (GUILayout.Button("Show apprequests Dialog"))
        {
            // see Facebook's documentation for all the dialogs and parameters that they support
            var parameters = new Dictionary <string, string>
            {
                { "title", "This Is The Title" },
                { "message", "message goes here" }
            };
            FacebookBinding.showDialog("apprequests", parameters);
        }


        if (GUILayout.Button("Get Friends"))
        {
            Facebook.instance.getFriends(completionHandler);
        }


        if (_canUserUseFacebookComposer)
        {
            if (GUILayout.Button("Show Facebook Composer"))
            {
                // ensure the image exists before attempting to add it!
                var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
                if (!System.IO.File.Exists(pathToImage))
                {
                    pathToImage = null;
                }

                FacebookBinding.showFacebookComposer("I'm posting this from Unity with a fancy image: " + Time.deltaTime, pathToImage, "http://prime31.com");
            }
        }


        if (GUILayout.Button("Show Facebook Share Dialog"))
        {
            var parameters = new Dictionary <string, object>
            {
                { "link", "http://prime31.com" },
                { "name", "link name goes here" },
                { "picture", "http://prime31.com/assets/images/prime31logo.png" },
                { "caption", "the caption for the image is here" },
                { "description", "description of what this share dialog is all about" }
            };
            FacebookBinding.showFacebookShareDialog(parameters);
        }
    }
    private void secondColumnButtonsGUI()
    {
        if (GUILayout.Button("Post Image"))
        {
            var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
            if (!System.IO.File.Exists(pathToImage))
            {
                Debug.LogError("there is no screenshot avaialable at path: " + pathToImage);
                return;
            }

            var bytes = System.IO.File.ReadAllBytes(pathToImage);
            Facebook.instance.postImage(bytes, "im an image posted from iOS", completionHandler);
        }


        if (GUILayout.Button("Graph Request (me)"))
        {
            Facebook.instance.graphRequest("me", HTTPVerb.GET, (error, obj) =>
            {
                // if we have an error we dont proceed any further
                if (error != null)
                {
                    return;
                }

                if (obj == null)
                {
                    return;
                }

                // grab the userId and persist it for later use
                var ht = obj as Hashtable;
                userId = ht["id"].ToString();

                Debug.Log("me Graph Request finished: ");
                Prime31.Utils.logObject(ht);
            });
        }


        if (GUILayout.Button("Post Message"))
        {
            Facebook.instance.postMessage("im posting this from Unity: " + Time.deltaTime, completionHandler);
        }


        if (GUILayout.Button("Post Message & Extras"))
        {
            Facebook.instance.postMessageWithLinkAndLinkToImage("link post from Unity: " + Time.deltaTime, "http://prime31.com", "Prime31 Studios", "http://prime31.com/assets/images/prime31logo.png", "Prime31 Logo", completionHandler);
        }


        if (GUILayout.Button("Show Post Message Dialog"))
        {
            // parameters are optional. See Facebook's documentation for all the dialogs and paramters that they support
            var parameters = new Dictionary <string, string>
            {
                { "link", "http://prime31.com" },
                { "name", "link name goes here" },
                { "picture", "http://prime31.com/assets/images/prime31logo.png" },
                { "caption", "the caption for the image is here" }
            };
            FacebookBinding.showDialog("stream.publish", parameters);
        }


        if (GUILayout.Button("Get Friends"))
        {
            Facebook.instance.getFriends(completionHandler);
        }


        if (canUserUseFacebookComposer)
        {
            if (GUILayout.Button("Show Facebook Composer"))
            {
                // ensure the image exists before attempting to add it!
                var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
                if (!System.IO.File.Exists(pathToImage))
                {
                    pathToImage = null;
                }

                FacebookBinding.showFacebookComposer("I'm posting this from Unity with a fancy image: " + Time.deltaTime, pathToImage, "http://prime31.com");
            }
        }
    }
Beispiel #29
0
    void OnGUI()
    {
        // center labels
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;

        beginColumn();

        if (GUILayout.Button("Initialize Facebook"))
        {
            FacebookBinding.init();
        }


        if (GUILayout.Button("Login"))
        {
            // Note: requesting publish permissions here will result in a crash. Only read permissions are permitted.
            var permissions = new string[] { "email" };
            FacebookBinding.loginWithReadPermissions(permissions);
        }


        if (GUILayout.Button("Reauth with Publish Permissions"))
        {
            var permissions = new string[] { "publish_actions", "publish_stream" };
            FacebookBinding.reauthorizeWithPublishPermissions(permissions, FacebookSessionDefaultAudience.OnlyMe);
        }


        if (GUILayout.Button("Enable Frictionless Requests"))
        {
            FacebookBinding.enableFrictionlessRequests();
        }


        if (GUILayout.Button("Logout"))
        {
            FacebookBinding.logout();
        }


        if (GUILayout.Button("Is Session Valid?"))
        {
            bool isLoggedIn = FacebookBinding.isSessionValid();
            Debug.Log("Facebook is session valid: " + isLoggedIn);

            Facebook.instance.checkSessionValidityOnServer(isValid =>
            {
                Debug.Log("checked session validity on server: " + isValid);
            });
        }


        if (GUILayout.Button("Get Access Token"))
        {
            var token = FacebookBinding.getAccessToken();
            Debug.Log("access token: " + token);
        }


        if (GUILayout.Button("Get Granted Permissions"))
        {
            var permissions = FacebookBinding.getSessionPermissions();
            foreach (var perm in permissions)
            {
                Debug.Log(perm);
            }
        }


        endColumn(true);


        // toggle to show two different sets of buttons
        if (toggleButtonState("Show OG Buttons"))
        {
            secondColumnButtonsGUI();
        }
        else
        {
            secondColumnAdditionalButtonsGUI();
        }
        toggleButton("Show OG Buttons", "Toggle Buttons");

        endColumn(false);


        if (bottomRightButton("Twitter..."))
        {
            Application.LoadLevel("TwitterTestScene");
        }
    }
Beispiel #30
0
 // Gets the url used to launch the application. If no url was used returns string.Empty
 public string GetLaunchUrl()
 {
     return(FacebookBinding.getAppLaunchUrl());
 }