Advertisement

Unity Highscore SAVE

Started by May 26, 2019 05:04 PM
2 comments, last by elmar1498 5 years, 4 months 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

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

Advertisement

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