반응형
플레이팹 로그인이 되었다는 가정하에 진행
코드 작성
using System;
using System.Collections.Generic;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;
public class PlayfabManager : MonoBehaviour
{
List<FriendInfo> friendsList = new List<FriendInfo>();
private void DisplayPlayfabError(PlayFabError error) => Debug.LogError("error : " + error.GenerateErrorReport());
public void GetFriendList()
{
List<string> friendsList = new List<string>();
PlayFabClientAPI.GetFriendsList(new GetFriendsListRequest
{
IncludeSteamFriends = false,
IncludeFacebookFriends = true,
ProfileConstraints = new PlayerProfileViewConstraints
{
ShowStatistics = true
},
XboxToken = null
}, result =>
{
Debug.Log("Get FriendList successfully!");
this.friendsList = result.Friends;
for (int i = 0; i < this.friendsList.Count; i++)
{
friendsList.Add(this.friendsList[i].TitleDisplayName);
}
}, DisplayPlayfabError);
}
public void AddFriend(FriendIdType idType, string friendId) //친구 추가
{
var request = new AddFriendRequest();
switch (idType)
{
case FriendIdType.PlayFabId:
request.FriendPlayFabId = friendId;
break;
case FriendIdType.Username:
request.FriendUsername = friendId;
break;
case FriendIdType.Email:
request.FriendEmail = friendId;
break;
case FriendIdType.DisplayName:
request.FriendTitleDisplayName = friendId;
break;
}
PlayFabClientAPI.AddFriend(request, result =>
{
Debug.Log("Friend added successfully!");
}, DisplayPlayfabError);
}
public void RemoveFriend(FriendInfo friendInfo) //친구 삭제
{
PlayFabClientAPI.RemoveFriend(new RemoveFriendRequest
{
FriendPlayFabId = friendInfo.FriendPlayFabId
}, result =>
{
Debug.Log("Friend deleted successfully!");
friendsList.Remove(friendInfo);
}, DisplayPlayfabError);
}
}
반응형
'개발 > Playfab' 카테고리의 다른 글
유니티 플레이팹 가상화폐 돈 증가 감소 간단 구현 Unity Playfab (0) | 2024.02.11 |
---|---|
유니티 플레이팹 아이템 주기 Playfab Grant Item ToUser 간단 사용법 (0) | 2022.07.20 |
유니티 플레이팹 아이템 구매 Playfab Shop Purchase Item 간단 사용법 (0) | 2022.07.20 |
유니티 플레이팹 Json으로 타이틀 데이터 저장, 불러오기 Playfab (0) | 2022.07.19 |
유니티 플레이팹 애플 로그인 Playfab Sign ln with Apple Login 간단 구현 (0) | 2022.07.19 |
유니티 플레이팹 페이스북 로그인 Playfab Sign ln with Facebook Login 간단 구현 (0) | 2022.07.19 |
유니티 플레이팹 클라우드 스크립트 사용 Playfab CloudScripts 간단 사용법 (0) | 2022.07.12 |
유니티 플레이팹 타이틀 뉴스 가져오기 Playfab ReadTitleNews 간단 사용법 (0) | 2022.07.12 |
댓글