- Home /
Question by
WyattJ1834 · Jan 24, 2018 at 10:58 PM ·
c#android buildplayerprefscodepage
Playerprefs not saving
When I build to Android my playerprefs doesn't always save. Here is a section of my code
void Update () {
money = PlayerPrefs.GetFloat("money");
money_multiplier = PlayerPrefs.GetFloat("money multiplier");
money += 0.000001f * money_multiplier;
MoneyText.text = money.ToString("0.0000");
PlayerPrefs.SetFloat("money", money);
PlayerPrefs.Save();
}
If I close the app out of multitasking and then reopen it my "money" value isn't always saved and I end up losing in-game money. What's going wrong here?
Comment
Answer by UnityCoach · Jan 25, 2018 at 12:06 AM
PlayerPrefs.Save(); is not meant to be called. But if you want to force saving, you can do it outside of Update()
. Like in a Coroutine or specific event.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
increase playerprefs 1 Answer