Hey peeps
I'm trying to write a custom action that will get the profile image and store it in a variable here i have provided the code. I'm a complete noob so i know i just need some assistance here. but how can i make my ProfileImage = UserAvatar or must i only use Fsm objects?
using UnityEngine;
using System.Collections;
using Facebook.Unity;
using UnityEngine.UI;
namespace HutongGames.PlayMaker.Actions {
[ActionCategory("Facebook")]
[Tooltip("Facebook Login")]
public class Facebook_Login : FsmStateAction {
[UIHint(UIHint.Variable)]
public FsmObject ProfileImage;
[UIHint(UIHint.Variable)]
public FsmInt FsmPublicIntTest;
//public FsmI
[UIHint(UIHint.Variable)]
private GameObject UIFBAvatar;
[UIHint(UIHint.Variable)]
private int privateIntTest;
public override void Reset() {
}
public override void OnEnter()
{
DoMyAction();
}
void DoMyAction()
{
FB.LogInWithReadPermissions ();
AreWeLoggedIn ();
}
void GetFacebookProfilePicture(){
Debug.Log("GetFacebookProfilePicture");
FB.API (Util.GetPictureURL ("/me", 128, 128), HttpMethod.GET, ProfilePhotoCallback);
}
private void ProfilePhotoCallback (IGraphResult result)
{
Debug.Log("FProfilePhotoCallback");
Image UserAvatar = UIFBAvatar.GetComponent<Image>();
UserAvatar.sprite = Sprite.Create (result.Texture, new Rect (0, 0, 128, 128), new Vector2 (0, 0));
ProfileImage = UserAvatar;
}
public void AreWeLoggedIn(){
Debug.Log("AreWeLoggedIn");
if (FB.IsLoggedIn) {
Debug.Log ("going to get picture");
GetFacebookProfilePicture ();
} else {
Debug.Log ("error");
}
}
}
}
thanks in advance