반응형
플레이팹 로그인이 되었다는 가정하에 진행
코드 작성
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 List<ItemInstance> inventoryList = new List<ItemInstance>(); //리스트 선언
private void DisplayPlayfabError(PlayFabError error) => Debug.LogError("error : " + error.GenerateErrorReport());
public void GetUserInventory() //인벤토리 가져오기
{
PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), result =>
{
var Inventory = result.Inventory;
int gold = result.VirtualCurrency["GO"]; //가상화폐 가져오기
int crystal = result.VirtualCurrency["ST"]; //가상화폐 가져오기
if (Inventory != null)
{
for (int i = 0; i < Inventory.Count; i++)
{
inventoryList.Add(Inventory[i]);
}
foreach (ItemInstance list in inventoryList)
{
if (list.ItemId.Equals("ItemId"))
{
Debug.Log("ItemId");
}
if (list.ItemClass.Equals("ItemClass"))
{
Debug.Log("ItemClass");
}
if (list.ItemInstanceId.Equals("ItemInstanceId"))
{
Debug.Log("ItemInstanceId");
}
}
}
else
{
return;
}
}, DisplayPlayfabError);
}
}
플레이팹 Api 참고
반응형
'개발 > Playfab' 카테고리의 다른 글
유니티 플레이팹 유저 프로필 가져오기 Playfab GetProfile 간단 사용법 (0) | 2022.07.08 |
---|---|
유니티 플레이팹 유저 데이터 불러오기 Playfab GetUserData 간단 사용법 (0) | 2022.07.08 |
유니티 플레이팹 유저 데이터 가져오기 Playfab SetUserData 간단 사용법 (0) | 2022.07.08 |
유니티 플레이팹 통계 저장 불러오기 Playfab GetStatistics 간단 사용법 (0) | 2022.07.02 |
유니티 플레이팹 상점 카테고리 가져오기 Playfab GetCatalog 간단 사용법 (0) | 2022.07.02 |
유니티 플레이팹 구글 로그인 Playfab Sign In with Google Login 간단 구현 (0) | 2022.06.22 |
유니티 플레이팹 게스트 로그인 Playfab Sign In with Guest Login 간단 사용법 (0) | 2022.06.21 |
유니티 플레이팹 패키지 Playfab Unity SDK 설치 (0) | 2022.06.18 |
댓글