반응형

PlayerPrefs

 

 

PlayerPrefs 클래스는 유니티에서 제공해주는 데이터 관리 클래스이다.

해당 클래스는 int, float, string, bool 타입의 변수를 저장하고 로드하는 기능을 제공한다.

 

 

PlayerPrefs 은 (엑셀에서 두 개의 컬럼으로 구성되어 있는 것과 같이) key와 Value 의 쌍으로 묶여진 항목들의 리스트의 룩업 리스트 입니다. 

그리고 각 플랫폼별 알아서 저장해줍니다

Description

게임 세션(session)사이에 플레이어 preference를 저장하고, preference에 접근합니다.

 

Mac OS X 에서 PlayerPrefs는 ~/Library/Preferences 폴더에 unity.[company name].[product name].plist의 파일이름으로 저장되며,

On Mac OS X PlayerPrefs are stored in ~/Library/Preferences folder, in a file named unity.[company name].[product name].plist, where company and product names are the names set up in Project Settings. Windows 독립 플레이어에서 PlayerPrefs는 @@HKCU
Software
[company name]
[product name]@@ 키 아래의 레지스트리에 저장되며 standalone players.

웹 플레이어에서 PlayerPrefs는 Mac OS X에서 ~/Library/Preferences/Unity/WebPlayerPrefs아래에 HKCU\Software\[company name]\[product name] key, where company and product names are 웹 플레이어 URL 당, 한개의 preference 파일이 존재하며, 파일 크기는 1메가 바이트로 제한됩니다. 파일 크기가 이 제한 값을 초과하는 경우,

On Linux, PlayerPrefs can be found in ~/.config/unity3d/[CompanyName]/[ProductName] again using the company and product names specified in the Project Settings.

On Windows Store Apps, Player Prefs can be found in %userprofile%\AppData\Local\Packages\[ProductPackageId]>\LocalState\playerprefs.dat

On Windows Phone 8, Player Prefs can be found in application's local folder, See Also: Windows.Directory.localFolder

On Android data is stored (persisted) on the device. The data is saved in SharerPreferences. C#/JavaScript, Android Java and Native code can all access the PlayerPrefs data. The PlayerPrefs data is physically stored in /data/data/pkg-name/shared_prefs/pkg-name.xml.

WebPlayer

On Web players, PlayerPrefs are stored in binary files in the following locations:

Mac OS X: ~/Library/Preferences/Unity/WebPlayerPrefs

Windows: %APPDATA%\Unity\WebPlayerPrefs

웹 플레이어에서 PlayerPrefs는 Mac OS X에서 ~/Library/Preferences/Unity/WebPlayerPrefs아래에

There is one preference file per Web player URL and the file size is limited to 1 megabyte. If this limit is exceeded, SetInt, SetFloat and SetString will not store the value and throw a PlayerPrefsException.

Static Functions

DeleteAll preference에서 모든 key와 값들을 제거합니다. 사용 시 경고가 뜹니다.
DeleteKey 키와 대응하는 값을 삭제합니다.
GetFloat Preference 파일에 존재하는 /key/에 대응하는 값을 반환합니다.
GetInt Preference 파일에 존재하는 /key/에 대응하는 값을 반환합니다.
GetString Preference 파일에 존재하는 /key/에 대응하는 값을 반환합니다.
HasKey 키가 존재하는지 확인합니다.
Save 수정된 모든 preferences를 디스크에 씁니다.
SetFloat /key/로 식별된 Preference의 값을 설정합니다.
SetInt /key/로 식별된 Preference의 값을 설정합니다.
SetString /key/로 식별된 Preference의 값을 설정합니다.

 

ref : https://docs.unity3d.com/kr/530/ScriptReference/PlayerPrefs.html

 

반응형

+ Recent posts