- Home /
Question by
Wesley21spelde · Nov 23, 2018 at 12:26 PM ·
facebooknot workingsdkpictureprofile
facebook profile pic not working
When i logg in my name shows up so that works but my profile picture doesnt show up i did put the profilepic game object dropbox
this is my script problem is at the bottom of the script in ( void DisplayProfilePic(IGraphResult result)
using System;
using System.Collections.Generic;
using Facebook.Unity;
using UnityEngine;
using UnityEngine.UI;
public class FBScript : MonoBehaviour
{
public GameObject BPMLogo;
public GameObject DialogLoggedIn;
public GameObject DialogLoggedOut;
public GameObject DialogLogUsername;
public GameObject DialogLogProfilePic;
void Awake()
{
FB.Init(SetInit, OnHideUnity);
}
void SetInit()
{
Debug.Log("FaceBook Init done");
if (FB.IsLoggedIn)
{
Debug.Log("FB is Logged in");
}
else
{
Debug.Log("FB is Not! Logged in");
}
DealWithFBMenus(FB.IsLoggedIn);
}
void OnHideUnity(bool isGameShown)
{
if (!isGameShown)
{
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
public void FBLogin()
{
List<string> permissions = new List<string>();
permissions.Add("public_profile");
FB.LogInWithReadPermissions(permissions, AuthCallback);
}
void AuthCallback(IResult result)
{
if (result.Error != null)
{
Debug.Log(result.Error);
}
else
{
if (FB.IsLoggedIn)
{
Debug.Log("FB is Logged in");
}
else
{
Debug.Log("FB is Not! Logged in");
}
DealWithFBMenus(FB.IsLoggedIn);
}
}
void DealWithFBMenus(bool isLoggedIn)
{
if (isLoggedIn)
{
DialogLoggedIn.SetActive(true);
DialogLoggedOut.SetActive(false);
BPMLogo.SetActive(false);
DialogLogProfilePic.SetActive(true);
FB.API("/me?fields=first_name", HttpMethod.GET, DisplayUsername);
FB.API("/me/picture?type=square&height=1286width=128", HttpMethod.GET, DisplayProfilePic);
}
else
{
DialogLoggedIn.SetActive(false);
DialogLoggedOut.SetActive(true);
BPMLogo.SetActive(true);
DialogLogProfilePic.SetActive(false);
}
}
void DisplayUsername(IResult result)
{
Text Username = DialogLogUsername.GetComponent<Text>();
if (result.Error == null)
{
Username.text = "Hi Thare," + result.ResultDictionary["first_name"];
}
else
{
Debug.Log(result.Error);
}
}
void DisplayProfilePic(IGraphResult result)
{
if ( result.Texture != null)
{
SpriteRenderer ProfilePic = DialogLogProfilePic.GetComponent<SpriteRenderer> ();
ProfilePic.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0));
ProfilePic.GetComponent<SpriteRenderer>();
}
}
}
Comment