PlayerPref.Set자료형("문자열 키값", 저장할 값);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
using UnityEngine;
using System.Collections;
public class csTest : MonoBehaviour {
int currentScore;
int highScore;
string currentPlayerName;
string highScorePlayerName;
void SaveData(){
// 현재 점수를 저장
PlayerPrefs.SetInt("Score", currentScore);
// 최고점에 현재점수를 저장
PlayerPrefs.SetInt("HighScore", currentScore);
// 현재 이름을 저장
PlayerPrefs.SetString("HighScoreName", currentPlayerName);
}
void GetData(){
// 최고점은 highscore란에 저장된 현재의 점수를 가져온다
highScore = PlayerPrefs.GetInt("HighScore");
// 저장된 현재 이름을 가져온다
highScorePlayerName = PlayerPrefs.GetString(
"HighScoreName", "N/A");
}
}
| cs |
SetInt |
key에의해 식별되는 환경의 값을 설정합니다.
|
GetInt |
만약 그것이 존재한다면 환경설정 파일에서 key에 해당하는 값을 반환합니다.
|
SetFloat |
key에의해 식별되는 환경의 값을 설정합니다.
|
GetFloat |
만약 그것이 존재한다면 환경설정 파일에서 key에 해당하는 값을 반환합니다.
|
SetString |
key에의해 식별되는 환경의 값을 설정합니다.
|
GetString |
만약 그것이 존재한다면 환경설정 파일에서 key에 해당하는 값을 반환합니다.
|
HasKey |
만약 환경설정에서 key가 존재한다면 true를 반환합니다.
|
DeleteKey |
환경설정으로부터 그것의 값에 해당하고 key를 제거합니다.
|
DeleteAll |
환경설정으로부터 모든 키와 값을 제거합니다. 조심해서 사용하세요.
|