Call PlayerPrefs.Save
after PlayerPrefs.SetInt
. That will likely solve your problem.
void OnApplicationQuit()
{
PlayerPrefs.SetInt("numerator", numerator);
PlayerPrefs.Save();
}
If that does not solve your problem, do the save operation in the OnApplicationPause
or OnDisable
function.
void OnApplicationPause(bool pauseStatus)
{
if (pauseStatus)
{
PlayerPrefs.SetInt("numerator", numerator);
PlayerPrefs.Save();
}
}
If both of these fail, Please look here for how to use Json to save and load game data.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…