コード例 #1
0
    IEnumerator GetFriendTexture(string uid)
    {
        string url = FBUtil.GetPictureURL(uid, 128, 128);
        WWW    www = new WWW(url);

        yield return(www);

        friendImages.Add(uid, (Texture)www.texture);
    }
コード例 #2
0
ファイル: FBHolder.cs プロジェクト: JochemKlingeler/WordUp
    void HandleUserName(FBResult result)
    {
        if (result.Error != null)
        {
            FB.API(FBUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, HandleAvatar);
            return;
        }

        profile = FBUtil.DeserializeJSONProfile(result.Text);
        Text UserMsg = UIFB_UserName.GetComponent <Text>();

        UserMsg.text = "Hallo, " + profile["first_name"];
    }
コード例 #3
0
ファイル: FBHolder.cs プロジェクト: JochemKlingeler/WordUp
    void HandleAvatar(FBResult result)
    {
        //If avatar GET call results in an error, retry calling it
        if (result.Error != null)
        {
            FB.API(FBUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, HandleAvatar);
            return;
        }
        //Get empty img of UI
        Image UserAvatar = UIFB_Avatar.GetComponent <Image>();

        //Fill this img with the correct FB profile picture
        UserAvatar.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0));
    }
コード例 #4
0
ファイル: FBHolder.cs プロジェクト: JochemKlingeler/WordUp
    private void ScoresCallback(FBResult result)
    {
        //Deserialize JSON result friends scores
        scoresList = FBUtil.DeserializeScores(result.Text);

        //Empty scorelist UI
        foreach (Transform item in ScoreScrollList.transform)
        {
            GameObject.Destroy(item.gameObject);
        }

        foreach (object score in scoresList)
        {
            var entry = (Dictionary <string, object>)score;
            var user  = (Dictionary <string, object>)entry["user"];

            GameObject ScorePanel;
            ScorePanel = Instantiate(ScoreEntryPanel) as GameObject;
            ScorePanel.transform.parent = ScoreScrollList.transform;

            //get name of friend + score
            Transform ScoreName  = ScorePanel.transform.Find("FriendName");
            Transform ScoreScore = ScorePanel.transform.Find("FriendScore");
            Text      scoreName  = ScoreName.GetComponent <Text>();
            Text      scoreScore = ScoreScore.GetComponent <Text>();

            scoreName.text  = user["name"].ToString();
            scoreScore.text = entry["score"].ToString();

            //get friend avatar
            Transform UserAvatar = ScorePanel.transform.Find("FriendAvatar");
            Image     userAvatar = UserAvatar.GetComponent <Image>();;

            FB.API(FBUtil.GetPictureURL(user["id"].ToString(), 128, 128), Facebook.HttpMethod.GET, delegate(FBResult pictureResult)
            {
                if (pictureResult.Error != null)
                {
                    Debug.Log(pictureResult.Error);
                }
                else
                {
                    userAvatar.sprite = Sprite.Create(pictureResult.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0));
                }
            });
        }
    }
コード例 #5
0
ファイル: FBHolder.cs プロジェクト: JochemKlingeler/WordUp
    void HandleFBMenus(bool isLoggedIn)
    {
        //If user is logged in menu is shown and filled with data
        if (isLoggedIn)
        {
            UIFB_IsLoggedIn.SetActive(true);
            UIFB_IsNotLoggedIn.SetActive(false);

            //get avatar
            FB.API(FBUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, HandleAvatar);

            //get username
            FB.API("/me?fields=id,first_name", Facebook.HttpMethod.GET, HandleUserName);

            // Check for Achievements
            GameControl.control.AchievementCheck();
            GameControl.control.FBlogin = true;
        }
        else
        {
            UIFB_IsLoggedIn.SetActive(false);
            UIFB_IsNotLoggedIn.SetActive(true);
        }
    }