- Home /
How can i save a variable for only one scene?
I am using the same scripts for all my scenes, and I have a variable balance, when I save it in playerprefs , all my scenes have the same balance when I load it, but each scene is a different world, each world should have a separate balance, can i save the variable balance for each scene individually, or do i have to make separate scripts for each scene???
forgot to mention my balance variable is in my gamemanager script
Answer by Stratosome · Aug 26, 2018 at 05:25 AM
Hey you!
If you're wanting to save each level score using PlayerPrefs like that, what you could do is instead of making multiple scripts, just change the name used for the score in PlayerPrefs. For example:
Level1_Highscore: 100
Level2_Highscore: 0
Level3_Highscore: 0
...
So, you could just make the name of your PlayerPref variable, well, a variable. Perhaps a public variable that you could set in the inspector. With this, you could go to that script in each scene, and just set the different name in the inspector. Kinda make sense? Hopefully that's useful.
THAN$$anonymous$$ YOU SOOOOOOOOOOOO $$anonymous$$UCHHHHH!!!!! now that i know how to save on individual scenes and across all scenes, the game has new possibilities, i cant thank you enough!!!!
Your answer
Follow this Question
Related Questions
Save score in Unity 1 Answer
Playerprefs to save unlocked button 2 Answers
Save values on different objets with same script? 1 Answer
Is it safe to save values in a prefab instead of using PlayerPrefs? 0 Answers
save unlocked character by Playerprefs 3 Answers