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

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.