int형식 저장 불러오기ㅣPlayFab





PlayFabManager.Cs 소스입니다




using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine.UI;

public class PlayFabManager : MonoBehaviour
{
    public InputField EmailInput, PasswordInput, UsernameInput, Input_1, Input_2, Input_3;
    public Text LogText, StatText;


    public void Login()
    {
        var request = new LoginWithEmailAddressRequest { Email = EmailInput.text, Password = PasswordInput.text };
        PlayFabClientAPI.LoginWithEmailAddress(request, (result) => LogText.text = "로그인 성공", (error) => LogText.text = "로그인 실패");
    }

    public void Register()
    {
        var request = new RegisterPlayFabUserRequest { Email = EmailInput.text, Password = PasswordInput.text, Username = UsernameInput.text };
        PlayFabClientAPI.RegisterPlayFabUser(request, (result) => LogText.text = "회원가입 성공", (error) => LogText.text = "회원가입 실패");
    }

    public void SetStat()
    {
        PlayFabClientAPI.UpdatePlayerStatistics(new UpdatePlayerStatisticsRequest
        {
            Statistics = new List<StatisticUpdate>
            {
                new StatisticUpdate {StatisticName = "Input_1", Value = int.Parse(Input_1.text)},
                new StatisticUpdate {StatisticName = "Input_2", Value = int.Parse(Input_2.text)},
                new StatisticUpdate {StatisticName = "Input_3", Value = int.Parse(Input_3.text)}
            }
        },
        (result) => { StatText.text = "값 저장됨"; },
        (error) => { StatText.text = "값 저장실패"; });
    }

    public void GetStat()
    {
        PlayFabClientAPI.GetPlayerStatistics(
            new GetPlayerStatisticsRequest(),
            (result) =>
            {
                StatText.text = "";
                foreach (var eachStat in result.Statistics)
                    StatText.text += eachStat.StatisticName + " : " + eachStat.Value + "\n";
            },
            (error) => { StatText.text = "값 불러오기 실패"; });
    }
}