コード例 #1
0
    public void ToggleFacebookLink()
    {
        if (PF_PlayerData.accountInfo.FacebookInfo != null)
        {
            Action <bool> afterCheck = (bool response) =>
            {
                if (response == true)
                {
                    //unlink
                    UnityAction afterUnlink = () =>
                    {
                        Text txt = this.linkToFaceBook.GetComponentInChildren <Text>();
                        txt.color = Color.red;
                        txt.text  = GlobalStrings.LINK_FB_BTN_MSG;
                        this.facebookPicture.overrideSprite = null;
                        Debug.Log("NEED ACCOUNT REFRESH???");
                        PF_PlayerData.accountInfo.FacebookInfo = null;
                        this.changedLoginState = true;
                    };

                    PF_PlayerData.UnlinkFBAccount(afterUnlink);
                }
            };

            DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.CONFIRM_UNLINK_PROMPT, GlobalStrings.CONFIRM_UNLINK_MSG, afterCheck);
        }
        else
        {
            // link
            UnityAction afterLink = () =>
            {
                Text btnText = this.linkToFaceBook.GetComponentInChildren <Text>();
                btnText.text  = GlobalStrings.UNLINK_FB_BTN_MSG;
                btnText.color = Color.green;


                Debug.Log("NEED ACCOUNT REFRESH???");
                this.changedLoginState = true;
                PF_PlayerData.accountInfo.FacebookInfo = new UserFacebookInfo();

                UnityAction <Texture2D> afterGetPhoto = (Texture2D tx) =>
                {
                    facebookPicture.overrideSprite = Sprite.Create(tx, new Rect(0, 0, 128, 128), new Vector2());
                };

                StartCoroutine(FacebookHelperClass.GetPlayerProfilePhoto(FetchWebAsset, afterGetPhoto));
            };

            PF_PlayerData.LinkFBAccount(afterLink);
        }
    }
コード例 #2
0
    private void UpdateFacebookStatusButton()
    {
        Debug.Log("UpdateFacebookStatusButton: " + FB.IsLoggedIn);
        var txt = linkToFaceBook.GetComponentInChildren <Text>();

        txt.text = FB.IsLoggedIn ? GlobalStrings.UNLINK_FB_BTN_MSG : GlobalStrings.LINK_FB_BTN_MSG;

        facebookPicture.overrideSprite = null;
        if (FB.IsLoggedIn)
        {
            UnityAction <Texture2D> afterGetPhoto = tx =>
            {
                facebookPicture.overrideSprite = Sprite.Create(tx, new Rect(0, 0, 128, 128), Vector2.zero);
            };
            StartCoroutine(FacebookHelperClass.GetPlayerProfilePhoto(FetchWebAsset, afterGetPhoto));
        }
    }
コード例 #3
0
    public void Init()
    {
        if (PF_PlayerData.accountInfo != null)
        {
            this.changedLoginState = false;
            displayName.text       = PF_PlayerData.accountInfo.TitleInfo.DisplayName;
            if (string.IsNullOrEmpty(PF_PlayerData.accountInfo.Username) || string.IsNullOrEmpty(PF_PlayerData.accountInfo.PrivateInfo.Email))
            {
                accountStatus.color = Color.red;
                accountStatus.text  = GlobalStrings.ACT_STATUS_UNREG_MSG;
                this.registerAccount.gameObject.SetActive(true);
                this.resetPassword.gameObject.SetActive(false);
            }
            else
            {
                accountStatus.color = Color.green;
                accountStatus.text  = GlobalStrings.ACT_STATUS_REG_MSG;
                this.registerAccount.gameObject.SetActive(false);
                this.resetPassword.gameObject.SetActive(true);
            }



            if (PF_PlayerData.showAccountOptionsOnLogin == true)
            {
                this.isShownOnLogin = true;
                this.showOnLogin.GetComponent <Image>().overrideSprite = this.checkedBox;
            }
            else
            {
                this.isShownOnLogin = false;
                this.showOnLogin.GetComponent <Image>().overrideSprite = this.uncheckedBox;
            }


            if (PF_PlayerData.accountInfo.FacebookInfo != null)
            {
                Text btnText = this.linkToFaceBook.GetComponentInChildren <Text>();
                btnText.text = GlobalStrings.UNLINK_FB_BTN_MSG;
                //btnText.color = Color.green;


                UnityAction <Texture2D> afterGetPhoto = (Texture2D tx) =>
                {
                    facebookPicture.overrideSprite = Sprite.Create(tx, new Rect(0, 0, 128, 128), new Vector2());
                };

                StartCoroutine(FacebookHelperClass.GetPlayerProfilePhoto(FetchWebAsset, afterGetPhoto));
            }
            else
            {
                Text btnText = this.linkToFaceBook.GetComponentInChildren <Text>();
                btnText.text = GlobalStrings.LINK_FB_BTN_MSG;
                //btnText.color = Color.red;
                facebookPicture.overrideSprite = null;
            }


                        #if UNITY_IPHONE
            UnityEngine.iOS.NotificationServices.RegisterForNotifications(UnityEngine.iOS.NotificationType.Alert | UnityEngine.iOS.NotificationType.Badge | UnityEngine.iOS.NotificationType.Sound, true);
                        #endif

            if (PF_PlayerData.isRegisteredForPush == true)
            {
                this.isRegisteredForPush = true;
                this.registerPush.GetComponent <Image> ().overrideSprite = this.checkedBox;
            }
            else
            {
                this.isRegisteredForPush = false;
                this.registerPush.GetComponent <Image>().overrideSprite = this.uncheckedBox;
            }
        }
    }