- Home /
PlayerPrefs Bug
I can't set the "UnityGraphicsQuality" using PlayerPrefs.SetInt("UnityGraphicsQuality", QLevel) and QLevel is the right value. UnityGraphicsQuality will be set until I exit the game and start it again, so the value saves so I can see it in regedit, but when I start the game again the value gets set to 3 which is the value I started being before setting it.
I'm using this code to apply it:
if (GUI.Button(Rect(Screen.width/2 - 100, Screen.height/2 + 52, 200, 25), "Apply")) {
PlayerPrefs.SetInt("UnityGraphicsQuality", QLevel);
QualitySettings.SetQualityLevel(PlayerPrefs.GetInt("UnityGraphicsQuality"));
PlayerPrefs.Save();
log("Settings applied!");
}
And this code to toggle it:
if (GUI.Button(Rect(Screen.width/2 - 100, Screen.height/2, 200, 25),"Quality: " + QualitySettings.names[QLevel])) {
if (QLevel != 5) {
QLevel += 1;
} else {
QLevel = 0;
}
}
And last this code to load it:
var QLevel : int;
function Start() {
if (PlayerPrefs.HasKey("UnityGraphicsQuality")) {
QLevel = PlayerPrefs.GetInt("UnityGraphicsQuality");
}
}
Did you set 3 for QLevel in the Unity editor/inspector? $$anonymous$$ight be defaulting to that from there.. remove it then try again.
I set it to 0 and I think the reason it might be reseting itself is that I disabled the start up configuration.
Not sure what you mean by disabled the start up configuration, but is it working?
The unity configuration where you set resolution, quality, monitor and controls. When you run the Application it is a pop up where you have to click play after changing your settings.
It sounds like your actual code has more going on that you've shown here. Can you post some code that reproduces just the PlayerPrefs issue? If not, it seems likely the problem is in your own scripting.
Your answer
Follow this Question
Related Questions
Save Quality settings 4 Answers
Instantiate a prefab just one time 1 Answer
Saving for a Level Editor 1 Answer
Accomplishments in each Level not Saving 2 Answers