본문 바로가기
개발/Playfab

유니티 플레이팹 유저 프로필 가져오기 Playfab GetProfile 간단 사용법

by SPNK 2022. 7. 8.
반응형

플레이팹 로그인이 되었다는 가정하에 진행

 

유니티 플레이팹 게스트 로그인 Playfab Sign In with Guest Login 간단 사용법

코드 작성 using PlayFab; using PlayFab.ClientModels; using PlayFab.Json; using PlayFab.ProfilesModels; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using EntityKey = PlayFab.ProfilesMod

parksh3641.tistory.com

 


데이터 가져오기

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 GetProfile(string playFabId)
    {
        string countryCode = "";
        string displayName = "";
        int score = 0;

        PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest()
        {
            PlayFabId = playFabId,
            ProfileConstraints = new PlayerProfileViewConstraints()
            {
                ShowLocations = true,
                ShowDisplayName = true,
                ShowStatistics = true
            }
        }, result =>
        {
            countryCode = result.PlayerProfile.Locations[0].CountryCode.Value.ToString();
            displayName = result.PlayerProfile.DisplayName;
            score = result.PlayerProfile.Statistics.Find(match => match.Name == "Score").Value;

        }, DisplayPlayfabError);
    }
}

 


참고할만한 글

 

자습서 플레이어 프로필 가져오기 - PlayFab

GetPlayerProfile 및 PlayerProfileViewConstraints API를 사용하여 플레이어 프로필 데이터를 가져오는 방법을 설명합니다.

docs.microsoft.com

 

반응형

댓글