- Home /
Overall Quality Horizontal Slider
Hi everyone, I'm trying to make a horizontal slider that will control overall quality. I'm trying to do something similar to what the Bootcamp demo did. I can't get it to work because QualitySettings.currentLevel isn't an integer. Is there a way to make custom variables like QualitySettings.currentLevel work with a horizontal slider?
public int overallQualityInt;
overallQualityInt = Mathf.RoundToInt(GUILayout.HorizontalSlider(overallQualityInt, 0, 4,GUILayout.Width(150), GUILayout.Height(35)));
QualitySettings.currentLevel = Mathf.RoundToInt(Mathf.Pow(2, overallQualityInt));
I think that the QualitySettings.currentLevel value is deprecated in Unity 4, so I cannot check if it is readonly, but this method should work great for you. Originally, I was thinking you could use a switch to set this, but using the SetQualityFunction will probably yield the best results.
int overallQualityInt = GUILayout.HorizontalSlider(overallQualityInt, 0, 4,GUILayout.Width(150), GUILayout.Height(35);
QualitySettings.SetQualityLevel(overallQualityInt);
I really don't want to do that, unless it's my last resort and I have no other choice.
So what is the range of the variable the the currentLevel is expecting? If it wants something 0-1 and the slider goes 0-10, then you could scale the slider value appropriately.
I don't understand. currentLevel doesn't accept integers or equal signs. You just mentioned what function you need to use with QualitySettings in order to change it and that is QualitySettings.SetQualityLevel(someLevel); .
I ment I didn't want to use a Switch Statement. Yes it did work with the SetQualityLevel function.
Answer by Ochreous · Oct 03, 2013 at 12:47 AM
I found a way to make it work. You just change the SetQualityLevel's integer to overallQualityInt.
int overallQualityInt = GUILayout.HorizontalSlider(overallQualityInt, 0, 4,GUILayout.Width(150), GUILayout.Height(35);
QualitySettings.SetQualityLevel(overallQualityInt);
awww man, you could have selected my answer ins$$anonymous$$d of typing in the exact same thing and clai$$anonymous$$g it for yourself. That's not really fair. I edited my typo as you can see in the version history of my answer.
I think it's not possible to see version history of an answer if you're not author, or possibly moderator. But if there was really only a typo, then I agree that original answer should have been accepted...