PlayerPrefs
// 保存玩家數(shù)據(jù)
PlayerPrefs.SetString(LoginName, _nameInput.text);
PlayerPrefs.SetInt(Password, int.Parse(_passwordInput.text));
PlayerPrefs.SetFloat(AudioKey, _audioSlider.value);
// 從玩家偏好設(shè)置中獲取key對應(yīng)的值
_nameInput.text = PlayerPrefs.GetString(LoginName);
_passwordInput.text = PlayerPrefs.GetInt(Password).ToString();
_audioSlider.value = PlayerPrefs.GetFloat(AudioKey);
JSON(JaveScripts Object Notation)
是一種輕量級的數(shù)據(jù)交換格式,是存儲和交換文本信息的語法 客戶端 - 服務(wù)器
獨立于語言的文本格式
JSON 語法規(guī)則
數(shù)據(jù)在 名稱/值 的對中(類似于字典的鍵值對應(yīng))
數(shù)據(jù)由逗號分隔
大括號保存對象
中括號保存數(shù)組
JSON的值
"FirstName":"Jack"
名稱和值在雙引號中领炫,中間用冒號分隔(注意:名稱key必須是字符串)
數(shù)據(jù)可以是數(shù)字(整數(shù)偶垮,浮點) ? 字符串在雙引號中 ??邏輯值(true 或 false)
數(shù)組在中括號中,對象在大括號中
JSON 大括號中保存對象
{"FirstName":"Jack","LastName":"Wang"}
JSON 數(shù)組帝洪,中括號中
{
" Employee " : 雇員類
[
{"FirstName":"Jack","LastName":"Wang"},
{"FirstName":"Jone","LastName":"Lee"},
{"FirstName":"Peter","LastName":"Zhang"},
]
}
訪問JSON數(shù)據(jù)
Employee[0][FirstName] ? 訪問形式類似于C#數(shù)組取值
訪問數(shù)據(jù)的時候是通過名稱(key)獲取值數(shù)據(jù)的似舵,所以名稱必須提前獲知(可以通過日志輸出,或者由JSON數(shù)據(jù)構(gòu)造者提供)
修改數(shù)據(jù)(寫數(shù)據(jù))
Employee[0][FirstName]="Rose";
插件? -? LitMiniJson 下載"https://github.com/nightyan/LitMiniJson/tree/master/LitMiniJSON/Json"
http://json.org ?JSON 官網(wǎng)?
Protobuf
用JSON擴展字段