- Home /
Changing quality settings on all levels
I am making a game where I have an options menu in a separate class. I want the player to be able change the quality settings in game, so I use a toggle group and this line of code:
QualitySettings.currentLevel = QualityLevel.Fastest;
My problem is that when i change scene back to the game, the quality settings reset. Anny idea how to do this? I've tried to add:
DontDestroyOnLoad(transform.gameObject);
Now when I go back to the game the setting stay the same, but when I reopen the class to change something else, it resets.
Thanks
Answer by Landern · Sep 10, 2015 at 01:26 PM
Use the PlayerPrefs class to save the quality settings. Setting the object that carries the value for the quality settings on a GameObject marked not to be destroyed will carry that value while it's in scope in your game, so when you stop Playing the game in the editor you lose the GameObject that was in memory and everything is defaulted to whatever you set it to originally. You need to persist the setting and PlayerPrefs is the cheapest way to do with without creating your own implementation/serialization scheme.
Your answer
Follow this Question
Related Questions
How can I avoid a framerate drop when asynchronously loading scenes 0 Answers
Multiple scenes loads to multiple clients and server can have a parallel view of each client scene ? 1 Answer
Scene loading delay after upgrade 4.6 to 5. 0 Answers
Multiple scenes 2 Answers
Input refresh between scenes 0 Answers