1
我在unity3d 5.4中遇到了PlayerPrefs的一个问题。 (我使用的5.4,因为在5.5游戏破错误。)PlayerPrefs未在Android上保存
下面是代码:
void OnApplicationQuit() {
PlayerPrefs.SetInt("numerator", numerator);
}
这正常的编辑器,但在移动这是一个不同的故事。它什么都不做。
我在unity3d 5.4中遇到了PlayerPrefs的一个问题。 (我使用的5.4,因为在5.5游戏破错误。)PlayerPrefs未在Android上保存
下面是代码:
void OnApplicationQuit() {
PlayerPrefs.SetInt("numerator", numerator);
}
这正常的编辑器,但在移动这是一个不同的故事。它什么都不做。
拨打PlayerPrefs.Save
后PlayerPrefs.SetInt
。这可能会解决你的问题。
void OnApplicationQuit()
{
PlayerPrefs.SetInt("numerator", numerator);
PlayerPrefs.Save();
}
如果不解决您的问题,请在OnApplicationPause
或OnDisable
功能保存操作。
void OnApplicationPause(bool pauseStatus)
{
if (pauseStatus)
{
PlayerPrefs.SetInt("numerator", numerator);
PlayerPrefs.Save();
}
}
如果这两个失败,请look这里如何使用JSON来保存和载入游戏数据。
谢谢! 'OnApplicationPause'和'PlayerPrefs.Save'一起诀窍! –