아미(아름다운미소)

유니티 게임정보저장/로딩 (PlayerPrefs : SetInt, GetInt) 기능 본문

랭귀지/Unity

유니티 게임정보저장/로딩 (PlayerPrefs : SetInt, GetInt) 기능

유키공 2018. 4. 14. 09:00

유니티 게임정보저장/로딩 (PlayerPrefs) 기능

(1) PlayerPrefs 라는 클래스(기능)을 이용하면 간단하게 정보를 로컬(핸드폰/pc)에 저장/로딩가능
(2) 저장할때는 SetInt 가져올때는 GetInt 이라는 기능을 사용 (*타입에따라 명령어가다르다)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class monster : MonoBehaviour {
 
    void Start () {
        PlayerPrefs.SetInt ("Player Score : ", 50000);
        int score = PlayerPrefs.GetInt ("Player Score : ");
        Debug.Log ("best score " + score);
    }
     
 
    void Update () {
 
    }
}
Comments