본문 바로가기
개발/C#

유니티 C# 로컬 데이터 저장, 불러오기 PlayerPrefs 간단 사용법

by SPNK 2022. 6. 21.
반응형
  • 데이터 저장
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
    private void SetValue()
    {
        PlayerPrefs.SetFloat("Apple", 1.0f);

        PlayerPrefs.SetInt("Orange", 1);

        PlayerPrefs.SetString("Banana", "Banana");
    }
}

 

  • 데이터 불러오기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
    private void GetValue()
    {
        float apple = PlayerPrefs.GetFloat("Apple");

        int orange = PlayerPrefs.GetInt("Orange");

        string banana = PlayerPrefs.GetString("Banana");
    }
}
반응형

댓글