Static Functions
DeleteAll | Removes all keys and values from the preferences. Use with caution. |
DeleteKey | Removes key and its corresponding value from the preferences. |
GetFloat | Returns the value corresponding to key in the preference file if it exists. |
GetInt | Returns the value corresponding to key in the preference file if it exists. |
GetString | Returns the value corresponding to key in the preference file if it exists. |
HasKey | Returns true if key exists in the preferences. |
Save | Writes all modified preferences to disk. |
SetFloat | Sets the value of the preference identified by key. |
SetInt | Sets the value of the preference identified by key. |
SetString | Sets the value of the preference identified by key. |
Example Code:
using UnityEngine; using System.Collections; public class Teaser : MonoBehaviour { int rnd=0,data=0; // Use this for initialization void Start () { rnd= Random.Range(2, 6); data= PlayerPrefs.GetInt("Data"); Debug.Log("Data Loaded "+data); Debug.Log("Random Number "+rnd.ToString()); PlayerPrefs.SetInt("Data", rnd); Debug.Log("Data Saved "+rnd.ToString()); } }
No comments:
Post a Comment
Silahkan