playMaker

Author Topic: help with writing custom action for Facebook sdk  (Read 1401 times)

9TOFRIDAY

  • Playmaker Newbie
  • *
  • Posts: 39
help with writing custom action for Facebook sdk
« on: November 28, 2015, 01:14:01 PM »
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?

Code: [Select]
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
« Last Edit: November 28, 2015, 01:42:55 PM by 9TOFRIDAY »