自:http://www.unitymanual.com/blog-77510-2971.html?_dsign=ec64b1e5

 

测试脚本  saveData.cs 附着在MainCamera上。

[code]csharpcode:

using UnityEngine;

using System.Collections;

public class saveData : MonoBehaviour

{

 private string name="None";

 private int age=0;

 void Start()

 {

  Debug.Log("defalut value: name="+name+",age="+age);

 }



 void OnGUI()

 {

  if(GUI.Button(new Rect(20,40,40,20),"save"))

  {

   PlayerPrefs.SetString("Name","Kitty");

   PlayerPrefs.SetInt("Age",2);



   name=PlayerPrefs.GetString("Name");

   age=PlayerPrefs.GetInt("Age");

   Debug.Log("changed value: name="+name+",age="+age);

  }

 }

}

 

点击save按钮之后两个变量的值被改变并保存。

PlayerPrefs所存的数据在注册表中以图中4所在的名字文件下

(转)PlayerPrefs在Windows下存到哪里去了?

运行----regedit( 打开注册表)  HKEY_CURRENT_USER/software下

(转)PlayerPrefs在Windows下存到哪里去了?

(转)PlayerPrefs在Windows下存到哪里去了?(转)PlayerPrefs在Windows下存到哪里去了?

(转)PlayerPrefs在Windows下存到哪里去了?

相关文章:

  • 2021-08-23
  • 2021-11-15
  • 2021-06-04
  • 2022-01-17
  • 2021-05-25
  • 2021-08-15
  • 2021-07-02
  • 2022-01-12
猜你喜欢
  • 2021-12-22
  • 2021-04-01
  • 2022-01-05
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案