Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by archelyte_vz · Aug 25, 2017 at 03:22 PM · facebooksdkpictureblank

Facebook Friend Pictures Returning Blank on Leaderboard

I'm using Unity 2017.1.03f with Facebook SDK 7.10.

When I make the call for a player's friends list from the the API, everything else returns fine. I get their scores, their name and everything else I need...except the picture.

The picture keeps returning blank, as in a white square.

Here is my code:

 using UnityEngine;
 using UnityEngine.UI;
 using Facebook.Unity;
 using Facebook.MiniJSON;
 using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using System;

 private void ScoresCallback(IResult result) {
         RankInt = 1;
         IDictionary<string, object> data = result.ResultDictionary;
         List<object> scoreList = (List<object>) data["data"];
 
         foreach (Transform child in ScrollScoreList.transform) {
             GameObject.Destroy(child.gameObject);
         }
 
         foreach(object obj in scoreList) {
             var entry = (Dictionary<string, object>) obj;
             var user = (Dictionary<string , object>) entry ["user"];
 
 //            Debug.Log(user["name"].ToString() + " , " + entry["score"].ToString());
 
             GameObject scorePanel;
             scorePanel = Instantiate (ScoreEntryPanel) as GameObject;
             scorePanel.transform.SetParent(ScrollScoreList.transform, false);
 
             Transform FName = scorePanel.transform.Find ("FriendName");
             Transform FScore = scorePanel.transform.Find ("FriendScore");
             Transform FAvatar = scorePanel.transform.Find ("FriendAvatar");
             Transform FRank = scorePanel.transform.Find ("RankNumber");
 
             Text FnameText = FName.GetComponent<Text> ();
             Text FscoreText = FScore.GetComponent<Text> ();
             Text FrankText = FRank.GetComponent<Text>();
             Image FUserAvatar = FAvatar.GetComponent<Image> ();
 
             FnameText.text = user["name"].ToString();
             FscoreText.text = entry["score"].ToString();
             FrankText.text = "" + RankInt;
             RankInt += 1;
 
             FB.API (user["id"].ToString() + "/picture?width=128&height=128", HttpMethod.GET, delegate (IGraphResult picresult) {
                 FUserAvatar.sprite = Sprite.Create(picresult.Texture, new Rect(0,0,50,50), new Vector2 (0,0), 100);
                 if (picresult.Error != null) {
                     Debug.Log("Picture Error" + picresult.RawResult);
                 }
             });
 
             //ScoresDebug.text = result.RawResult;
         }
 
     }

The console is returning this: "Picture Error���� UnityEngine.Debug:Log(Object) c_AnonStorey1:<>m0(IGraphResult) (at Assets/Scripts/Facebook/FBScript.cs:267) Facebook.Unity.d_9:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)"

What I have tried:

  1. putting "https" + "://graph.facebook.com/" in front of user["id"].ToString()

  2. "/picture?width=128&height=128&redirect=false"

  3. FUserAvatar.overrideSprite

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FortisVenaliter · Aug 25, 2017 at 03:29 PM 0
Share

Two things:

You should check if the texture has problems or is null before creating the sprite.

Why do you ask for a 128x128 image if you create a sprite that's 50x50?

avatar image archelyte_vz FortisVenaliter · Aug 25, 2017 at 03:36 PM 0
Share

It was previously that way, but in many "answers" they didn't even include the error check, so I changed it to be an after thought. It returns null both ways.

It was also previously asking for a 50x50, but Facebook's scripts show it calling for a 128x128 in every example, so I gave it a shot to see if that may have been the issue. Their API has been very finicky about everything being exact.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

67 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

facebook profile pic not working 0 Answers

Facebook Android SDK won't post to wall. 1 Answer

Displaying profile pictures in all connected devices 1 Answer

facebook sdk problem 1 Answer

Facebook Login and Logout problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges