🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Unity Highscore SAVE

Started by
2 comments, last by elmar1498 5 years, 1 month ago

I want to save the highest time and spend it, but somehow only the time before that is saved and spent. Maybe someone can help me?

2.PNG

Advertisement

Unless you have a very specific reason not to, you should put your PlayerPrefs.Save calls AFTER the SetFloat calls.

First off, use code tags.

Second, variable names. 'm' and 'n' may make sense now, but they definitely won't from few months from now. Keep your variable names meaningful.

Third, remove duplicate code. Put "PlayerPrefs.Save()" outside the brackets (just before "highscorelayer.SetActive(false)". Remove other "PlayerPrefs.Save()" calls. This will also solve your original problem.

Finally, is there a reason for storing minute and seconds separately? Why not store time in seconds or milliseconds and resolve the number of minutes from that? This will basically half the highscore logic you've written.

 

 

This topic is closed to new replies.

Advertisement