반응형
플레이팹 로그인이 되었다는 가정하에 진행
코드 작성
using PlayFab;
using PlayFab.ClientModels;
using PlayFab.Json;
using PlayFab.ProfilesModels;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayfabManager : MonoBehaviour
{
private void DisplayPlayfabError(PlayFabError error) => Debug.LogError("error : " + error.GenerateErrorReport());
public void GetLeaderboarder(string name, Action<GetLeaderboardResult> callBack)
{
var requestLeaderboard = new GetLeaderboardRequest
{
StartPosition = 0,
StatisticName = name,
MaxResultsCount = 100,
ProfileConstraints = new PlayerProfileViewConstraints()
{
ShowLocations = true,
ShowDisplayName = true,
ShowStatistics = true
}
};
PlayFabClientAPI.GetLeaderboard(requestLeaderboard, callBack, DisplayPlayfabError);
}
}
리더보드 리스트 요청
using PlayFab;
using PlayFab.ClientModels;
using PlayFab.Json;
using PlayFab.ProfilesModels;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RankManager : MonoBehaviour
{
public PlayfabManager playfabManager;
void Awake()
{
playfabManager.GetLeaderboarder("Score", SetRanking);
}
public void SetRanking(GetLeaderboardResult result)
{
var curBoard = result.Leaderboard;
foreach (PlayerLeaderboardEntry player in curBoard)
{
string displayName = player.DisplayName;
string playFabId = player.PlayFabId;
int score = player.StatValue;
}
}
}
참고할만한 글
반응형
'개발 > Playfab' 카테고리의 다른 글
유니티 플레이팹 클라우드 스크립트 사용 Playfab CloudScripts 간단 사용법 (0) | 2022.07.12 |
---|---|
유니티 플레이팹 타이틀 뉴스 가져오기 Playfab ReadTitleNews 간단 사용법 (0) | 2022.07.12 |
유니티 플레이팹 서버 시간 가져오기 Playfab GetServerTime 간단 사용법 (0) | 2022.07.12 |
유니티 플레이팹 타이틀 데이터 불러오기 Playfab GetTitleInternal 간단 사용법 (0) | 2022.07.12 |
유니티 플레이팹 닉네임 변경, 불러오기 Playfab NickName 간단 사용법 (0) | 2022.07.08 |
유니티 플레이팹 유저 프로필 가져오기 Playfab GetProfile 간단 사용법 (0) | 2022.07.08 |
유니티 플레이팹 유저 데이터 불러오기 Playfab GetUserData 간단 사용법 (0) | 2022.07.08 |
유니티 플레이팹 유저 데이터 가져오기 Playfab SetUserData 간단 사용법 (0) | 2022.07.08 |
댓글