PlayerPrefs数据储存

来源:互联网 发布:mac用什么解压缩软件 编辑:程序博客网 时间:2024/06/05 08:09
PlayerPrefs数据储存
unity是一个静态类提供静态方法类
针对不同的平台的一种路径数据只有自己能解析
缺点  每次只能存一个数据 数据不能重名 重名会覆盖  键值对储存
usingUnityEngine;
usingSystem.Collections;

publicclassGameController : MonoBehaviour{
   voidStart() {
       PlayerPrefs.SetFloat("Score",1092f);
     
       floatscore = PlayerPrefs.GetFloat("Score");
    
       Debug.Log(score );
       PlayerPrefs.SetInt("Score", 111);
      
       intsc = PlayerPrefs.GetInt("Score");
      
       Debug.Log(sc );
    }
                
}