반응형
플레이팹 로그인이 되었다는 가정하에 진행
코드 작성
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
{
public string customId = "";
public string nickName = "";
private void DisplayPlayfabError(PlayFabError error) => Debug.LogError("error : " + error.GenerateErrorReport());
public void GetDisplayName()
{
PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest()
{
PlayFabId = customId,
ProfileConstraints = new PlayerProfileViewConstraints()
{
ShowDisplayName = true
}
},
(result) =>
{
nickName = result.PlayerProfile.DisplayName;
},
DisplayPlayfabError);
}
public void UpdateDisplayName(string nickname)
{
PlayFabClientAPI.UpdateUserTitleDisplayName(new UpdateUserTitleDisplayNameRequest
{
DisplayName = nickname
},
(result) =>
{
Debug.Log("Update User NickName : " + result.DisplayName);
},
DisplayPlayfabError);
}
}
반응형