Getting Texture from IResult (Facebook Unity SDK 7.0.3b)
Asked Answered
P

2

0

Hello and thanks for your attention. I'm in the midst of attempting to update my Unity/Facebook Canvas game to use the latest Facebook SDK, 7.0.3b. I see that they've made several changes, and that little or none of the documentation has been updated to reflect those changes as yet.

While it is all a bit confusing, I'm floundering around as best I can trying to fix the "breaking" changes, however the IResult replacement for FBResult has me a bit flummoxed, especially when trying to retrieve as user's profile picture. Previously, I could simply pull a texture from the FBResult, but IResult doesn't seem to have the same make up and I'm unsure as to how I should proceed.

Edited To Add: I see the same issue with returning Text from the IResult, which used to be a simple matter with FBResult. Surely I'm just missing something simple here, right?

Here is an example of the previous code I was using to accomplish this task. If anyone can provide me with an updated example, or send me in the right direction for making these necessary changes, I'd most certainly appreciate it. Thanks!

void FBProfilePicture(FBResult result)
{
    if(result.Error != null)
    {
        Debug.Log(gameObject.name + " reports: Problem retrieving FB profile picture!");
        return;
    }
    Image UserAvatar = UIFBAvatar.GetComponent<Image>();
    UserAvatar.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0));
    SpriteRenderer userPic = UserPic.GetComponent<SpriteRenderer>();
    userPic.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0));
}
Pistareen answered 9/9, 2015 at 19:0 Comment(0)
E
0

You have to do the following:

  1. Add 'this.Texture = result.texture;' to the GraphResult constructor.
  2. Add 'public Texture2D Texture { get; private set; }' to GraphResult.cs
  3. Add 'Texture2D Texture { get; }' to IGraphResult.cs, as well as 'using UnityEngine;'

With the changes in those 2 clases, now your IGraphResult will contain the Texture that you had before, and you can continue working like nothing happened!

Let me know how it turns out.

Eruption answered 5/10, 2015 at 21:20 Comment(0)
S
0

For anyone updating from the older SDKs.

result.error no longer returns null.

Change to this:

if (result.error == "") 
{
     Debug.Log(gameObject.name + " reports: Problem retrieving FB profile picture!");
     return;
}
Sleepy answered 17/8, 2017 at 23:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.