close
使用PlayerPrefs
可以用來存取一些簡單的資料
例如 設定值 畫質 影子 ...等遊戲常用設置
基本上找不到資料就用設定值
也不用怕被亂改資料.
注意在行動平台上,清除快取會造成PlayerPrefs資料消失。
using UnityEngine; using System.Collections; public class Example_ : MonoBehaviour { void Start () { Save(); Load(); } private void Save () { PlayerPrefs.SetInt("Key01", 1); PlayerPrefs.SetString("Key02", "Hellow"); PlayerPrefs.SetFloat("key03", 5.5f); } private void Load () { int nInt = PlayerPrefs.GetInt("Key01"); string sString = PlayerPrefs.GetString("Key02"); float fNum = PlayerPrefs.GetFloat("Key03"); Debug.Log("nInt: " + nInt.ToString() + ", sString: " + sString + ", fNum: " + fNum.ToString()); } }
結果圖
歡迎光臨 ~ Eg 程式筆記的天堂
當你看完此篇文章,如果你覺得文章不錯
可以留下鼓勵的留言~
將是我的撰寫更多相關文章的動力
文章標籤
全站熱搜