Sign In Register

How can we help you today?

Start a new topic
Answered

Unity / Facebook piping in Profile Pic using id

Hi,


I am able to create a new player in my player collection in GS. Now I want to use the FB id which now resides in:

...,

"externalids: {"FB": "1234"}, ...


I have been following this tutorial here: https://drive.google.com/file/d/0ByRUWa2F2BklNV8zUWtpX19nTFk/view


but using GameSparks.Api.Requests.FacebookConnectRequest() method won't get that bit of info. This other tutorial that teaches how to get that info (https://docs.gamesparks.net/tutorials/unity-tutorials-challenges-part-3-user-manager) is out of date, or at least I am unable to puzzle it together and would really appreciate help.


Thanks! 


Best Answer

Figured it out...To access the FB Id that I have on my GS server I use this


new AccountDetailsRequest().Send((response) =>

  {

   UpdateGUI(response.ExternalIds.GetString("FB"));

  });


Then I pass the FB ID into this:

var www = new WWW("http://graph.facebook.com/" + facebookId + "/picture?width=100&height=100");


I made a Gameobject with an image component called profilePic and then swapped it out like this:


Image userAvatar = profilePic.GetComponent<Image>();

userAvatar.sprite = Sprite.Create(www.texture, new Rect(0,0,100,100), new Vector2(0,0));


Hope this helps someone else!


Answer

Figured it out...To access the FB Id that I have on my GS server I use this


new AccountDetailsRequest().Send((response) =>

  {

   UpdateGUI(response.ExternalIds.GetString("FB"));

  });


Then I pass the FB ID into this:

var www = new WWW("http://graph.facebook.com/" + facebookId + "/picture?width=100&height=100");


I made a Gameobject with an image component called profilePic and then swapped it out like this:


Image userAvatar = profilePic.GetComponent<Image>();

userAvatar.sprite = Sprite.Create(www.texture, new Rect(0,0,100,100), new Vector2(0,0));


Hope this helps someone else!

Thanks,



Helped a lot :D 

Glad to hear it! I get so much help here, it feels nice to be able to give back!


1 person likes this
Login to post a comment