Unity本地持久化储存数据

来源:互联网 发布:数据安全工程师 编辑:程序博客网 时间:2024/06/02 02:04


储存数据        
PlayerPrefs.SetString("name", "warrior");             //设置字符串       
PlayerPrefs.SetInt("numberInt", 2);                      //设置整型        
PlayerPrefs.SetFloat("numberFloat", 0.3f);           //设置浮点型
 
获取数据
PlayerPrefs.GetFloat("numberFloat", 0.0f).ToString();   //获取浮点型        
Age = PlayerPrefs.GetInt("numberInt", 0).ToString();    //获取整型        
Name = PlayerPrefs.GetString("name", "");                  //获取字符串 


PlayerPrefs.DeleteAll();// 清除所有数据

原创粉丝点击