generated from pancake-llc/package
-
Notifications
You must be signed in to change notification settings - Fork 16
yenmoc edited this page Dec 16, 2022
·
1 revision
Simple Facebook Manager
Require install facebook
- Facebook application need create with type is
gaming
- If permission
gaming_user_picture
not include will return avartar, if include it will return profile picture
public Image prefab;
public Transform root;
private async void Start()
{
if (FacebookManager.Instance.IsLoggedIn)
{
FacebookManager.Instance.GetMeProfile(FacebookManager.Instance.OnGetProfilePhotoCompleted);
await UniTask.WaitUntil(() => !FacebookManager.Instance.IsRequestingProfile);
var o = Instantiate(prefab, root);
o.sprite = FacebookManager.CreateSprite(FacebookManager.Instance.ProfilePicture, Vector2.one * 0.5f);
}
}
public void Login() { FacebookManager.Instance.Login(OnLoginCompleted, OnLoginFaild, OnLoginError); }
private void OnLoginError() { }
private void OnLoginFaild() { }
private async void OnLoginCompleted()
{
await UniTask.WaitUntil(() => !FacebookManager.Instance.IsRequestingProfile);
var o = Instantiate(prefab, root);
o.sprite = FacebookManager.CreateSprite(FacebookManager.Instance.ProfilePicture, Vector2.one * 0.5f);
FacebookManager.Instance.GetMeFriend();
await UniTask.WaitUntil(() => !FacebookManager.Instance.IsRequestingFriend);
var p = FacebookManager.Instance.LoadProfileAllFriend();
await p;
for (int i = 0; i < FacebookManager.Instance.FriendDatas.Count; i++)
{
var result = Instantiate(prefab, root);
Debug.Log("friend : " + FacebookManager.Instance.FriendDatas[i].name);
result.sprite = FacebookManager.CreateSprite(FacebookManager.Instance.FriendDatas[i].avatar, Vector2.one * 0.5f);
}
}