Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 talyon · Feb 23, 2015 at 01:04 AM · c#spriteimagefacebook

Error facebook profile picture

Now trying to put the image of the profile of facebook in the ranking of my game.

Watching a tutorial (it's my first project) I wrote this script

 public void QueryScores()
 {
     FB.API ("/app/scores?fields=score,user.limit(30)", Facebook.HttpMethod.GET, ScoresCallback);
 }
 
 private void ScoresCallback (FBResult result)
 {
     Debug.Log ("Scores callback" + result.Text);
     scoresList = Util.DeserializeScores (result.Text);
     
     foreach(Transform child in ScoreScrollList.transform)
     {
         GameObject.Destroy (child.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;
         
         Transform ThisScoreScore = ScorePanel.transform.Find("Friend Score");
         
         Text ScoreScore = ThisScoreScore.GetComponent<Text>();
         
         ScoreScore.text = entry["score"].ToString ();
         
         Transform TheUserAvatar = ScorePanel.transform.Find ("Friend Avatar");
         Image UserAvatar = TheUserAvatar.GetComponent<Image>();
         
         
         FB.API (Util.GetPictureURL(user["id"].ToString (), 128,128), Facebook.HttpMethod.GET, delegate(FBResult pictureResult){
             
             if(pictureResult.Error != null) // if there was an error
             {
                 Debug.Log (pictureResult.Error);
             }
             else // if everything was fine
             {
                 UserAvatar.sprite = Sprite.Create (pictureResult.Texture, new Rect(0,0,128,128), new Vector2(0,0));
             }
             
         });
     }
     
 }

This is the error that gives me and the outcome of the script alt text

Is there anyone who might have no idea how to solve?

Thanks in advance to those who will respond

errore.png (20.8 kB)
Comment
Add comment · Show 1
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 talyon · Feb 23, 2015 at 04:42 PM 0
Share

Update: I'm not from the error, but can not download the profile picture, change to become a red question mark

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by zzzzzz789 · Feb 23, 2015 at 09:27 PM

The 'pictureResult.Texture' will not be auto populated with the fetched image from the Facebook. You will need to download the image separately. The URL of the picture is contained in the pictureResult.Text. These results are JSON formatted, so you will need to deserialize the URL prior to making a WWW call to download the image.

For example, here is code with no error handling: http://pastebin.com/R5v5XeAz

Comment
Add comment · Show 1 · Share
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 talyon · Feb 25, 2015 at 03:18 PM 0
Share

Yes, it works! But I'm wondering why in the tutorial everything worked perfectly with the code that I had, anyway thanks for the answer!

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

21 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

Related Questions

How to make a UI image change sprite through a script that is not attached to the UI image itself 0 Answers

How to snap UI element anchor relative to image sprite? 2 Answers

Why is Sprite a null? 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers


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