[Unity&]PlayerPrefs.GetString的使用案例

根据官方 案例PlayerPrefs.SetString 进行测试

 https://docs.unity3d.com/ScriptReference/PlayerPrefs.SetString.html


[Unity&]PlayerPrefs.GetString的使用案例[Unity&]PlayerPrefs.GetString的使用案例


PlayerPrefs:https://docs.unity3d.com/ScriptReference/PlayerPrefs.html

PlayerPrefs

在UnityEngine中

描述

在游戏会话之间存储和访问玩家喜好。

编辑/独立 

On MacOS PlayerPrefs存储在〜/ Library / Preferences文件夹中,名为unity。[company name]。[product name] .plist,其中公司和产品名称是“项目设置”中设置的名称。相同的.plist文件用于在编辑器和独立播放器中运行的两个项目。

在Windows上,PlayerPref存储在HKCU \ Software \ [公司名称] \ [产品名称]键下的注册表中,其中公司和产品名称是“项目设置”中设置的名称。

在Linux上,PlayerPrefs可以在〜/ .config / unity3d / [CompanyName] / [ProductName]中找到,使用“项目设置”中指定的公司和产品名称。

在Windows Store Apps上,可以在%userprofile%\ AppData \ Local \ Packages \ [ProductPackageId]> \ LocalState \ playerprefs中找到Player Prefs。

dat 在Windows Phone 8上,Player Prefs可以在应用程序的本地文件夹中找到,另请参见:Directory.localFolder

在Android上,数据存储(持久化)在设备上。数据保存在SharedPreferences中。C#/ JavaScript,Android Java和Native代码都可以访问PlayerPrefs数据。PlayerPrefs数据实际存储在/data/data/pkg-name/shared_prefs/pkg-name.xml中。

在WebGL上,PlayerPrefs使用浏览器的IndexedDB API进行存储。PlayerPrefs数据实际存储在/data/data/pkg-name/shared_prefs/pkg-name.xml中。在WebGL上,PlayerPrefs使用浏览器的IndexedDB API进行存储。PlayerPrefs数据实际存储在/data/data/pkg-name/shared_prefs/pkg-name.xml中。在WebGL上,PlayerPrefs使用浏览器的IndexedDB API进行存储。

静态功能

删除所有 从首选项中删除所有键和值。谨慎使用。
DELETEKEY 从首选项中删除键及其相应的值。
GetFloat 返回与首选项文件中的键对应的值(如果存在)。
GetInt 返回与首选项文件中的键对应的值(如果存在)。
的GetString 返回与首选项文件中的键对应的值(如果存在)。
HasKey 如果**存在于首选项中,则返回true。
保存 将所有修改的首选项写入磁盘。
的setFloat 设置由键识别的首选项的值。
SETINT 设置由键识别的首选项的值。
的SetString 设置由键识别的首选项的值。
由此可见,PlayerPrefs是一个 暂时存储在 Unity 的一个 存档。


参考资料2 存档的讲解。


参考资料:

1.PlayerPrefs.SetString

Sets the value of the preference identified by key.

https://docs.unity3d.com/ScriptReference/PlayerPrefs.SetString.html

2.

Unity 游戏存档 PlayerPrefs类的用法

http://www.cnblogs.com/qiaogaojian/p/5969855.html

3.

4.

5.