- Home /
"GetQualityLevel" is not a member of "QualitySettings"
Hello guys, basically my problem is that i'm creating an in-game Menu, with "options", "start game" and all that sort of things, and in the "options" tab I have a general quality setting. But my script isn't working, I read the Unity Scipt Reference page regarding all the Quality scripts (SetQualityLevel, GetQualityLevel, Increase and Decrease);
Here is my code (really simple):
var qualityLevel = QualitySettings.GetQualityLevel();
function Update () {
GetComponent.<TextMesh>().text = "Quality: " + qualityLevel;
}
And then I attach the script to a Text object, but i get an error from the compiler, saying that "GetQualityLevel" is not a member of "QualitySettings". WHAT IN THE WORLD does it mean? It's clearly written in the Reference page that to return the quality level you need to use that variable (Here is the page), am I doing something wrong? How can I make the script say what graphics setting I have?
var qualityLevel; //of whatever type is it.
function Awake()
{
qualityLevel = QualitySettings.GetQualityLevel();
}
I suspect you can only perform this action inside a function.
The problem is still the same: BCE0019: 'GetQualityLevel' is not a member of 'QualitySettings'. I really don't get it.
var qualityLevel : int = QualitySettings.GetQualityLevel();
according to the almighty docs , this should compile. one question, is the error co$$anonymous$$g from $$anonymous$$ono Develop/VS 2012 or Unity itself?. The error means what it means "GetQualityLevel" doesn't exists as far as the compiler is concerned. now we now for a fact that it DOES exists.
the question is, why is the compiler confused. Double check in your code that is spelled correctly. If the error appears in your script editor and not unity , restart the script editor. is that all of the code in the file? a missing "{" or ";" might be what throwing you and the compiler off.
also your code should be
GetComponent<Text$$anonymous$$esh>().text = "Quality: " + QualitySettings.names[qualityLevel];
The error is co$$anonymous$$g from Unity itself from the error bar at the bottom of the Unity Editor. If i copy/paste your code, i get 3 errors about some unexpected tokens (the ")" in "().", the "." in "()." and that the compiler was expecting a ";" at the end of "()."), and if i delete the function and leave the "var qualityLevel : int = etcetc" alone i get the same error about "GetQualityLevel" not being a member of "QualitySettings".
^now that is weird, it works perfectly on my end...at any rate your code that you posted isn't causing the problems, something else is. is there more of your code in that script? if so post it!
None else is getting the errors you are. so that tells me somewhere else in your code is at fault.
Answer by meat5000 · Dec 07, 2013 at 11:53 AM
If I use your script I get
GetQualityLevel can only be called from the main thread.
If I move the call to Awake it works nicely.
Do you have #pragma strict in your code?
The following works for me with no errors.
#pragma strict
var qualityLevel;
function Awake ()
{
qualityLevel = QualitySettings.GetQualityLevel();
Debug.Log(qualityLevel);
}
Yes I have #pragma strict, I only didn't write it in the pastebin because I didn't find it useful for you. That's strange, I get the same error with your code, and I updated Unity yesterday. Do you have the latest Unity?
Ok that's weird, in another project your code works, now I have got to find out what is the problem with my main project... there could be something that interferes with the quality settings? There's only another script on the TextObject used for Quality, this one:
var isVolumeButton = false;
var isOptionButton = false;
var isBackButton = false;
var is$$anonymous$$Button = false;
var is$$anonymous$$in2Button = false;
var is$$anonymous$$in1Button = false;
var isQuitButton = false;
public static var camera$$anonymous$$ove = 0;
function On$$anonymous$$ouseEnter()
{
//change the color of the text to green
renderer.material.color = Color.green;
}
function On$$anonymous$$ouseExit()
{
//change the color of the text back to white
renderer.material.color = Color.white;
}
function On$$anonymous$$ouseUp()
{
//are we dealing with the Quit button?
if(isQuitButton)
{
//quit the game
Application.Quit();
}
else if(is$$anonymous$$in1Button)
{
//load level 1
Application.LoadLevel(1);
}
else if(is$$anonymous$$in2Button)
{
//load level 2
Application.LoadLevel(2);
}
else if(is$$anonymous$$Button)
{
//move the camera
camera$$anonymous$$ove = 1;
}
else if(isBackButton){
//moves the camera back
camera$$anonymous$$ove = 0;
}
else if(isOptionButton){
//moves the camera to options
camera$$anonymous$$ove = 2;
}
else if(isVolumeButton){
//changes the volume
Send$$anonymous$$essage("point02");
}
}
This is the code for the buttons of my $$anonymous$$enu, I still didn't write the code about the Quality setting because of the "GetQualityLevel" problem
Answer by Raiden-Freeman · Dec 07, 2013 at 10:49 AM
I'm pretty certain, that you need to declare var qualityLever as an int. Try out:
var a : int;
function Start () {
a = QualitySettings.GetQualityLevel ();
Debug.Log(a);
}
Also it's an integer, not a string. It's best that you use this when assigning to text:
GetComponent<TextMesh>().text = "Quality: " + qualityLevel.ToString;
Also, remember that you need to call QualitySettings, only in functions like Awake and Start (I think).
Your answer
![](https://koobas.hobune.stream/wayback/20220613123626im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
troble with the Axis in unity 1 Answer
OnMouseUp not working in build? 0 Answers
MuzzleFlash not working 0 Answers
splatPrototypes not changing in exported game 0 Answers
WaitForSeconds not working in while 2 Answers