- Home /
Changing UI Text to the Quality Level
Hey Guys, I wanted to make a main menu and have the quality settings work by pushing a button and changing the quality level up or down. I manage to work the changing of quality level but I cannot figure out how to make the text change to the Quality level. Here is my script:
import UnityEngine.UI;
var qualityText : Transform;
var qualityLevel = QualitySettings.GetQualityLevel ();
function Start(){
}
function Update () {
qualityText.text = "" + qualityLevel;
}
function Increase()
{
QualitySettings.IncreaseLevel(true);
}
function Decrease()
{
QualitySettings.DecreaseLevel(true);
}
And here are the errors:
GetQualityLevel can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
ArgumentException: GetQualityLevel can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
QualityManager..ctor () (at Assets/EasyMenu/Resources/Scripts/QualityManager.js:4)
Answer by reddead12 · Dec 06, 2015 at 05:00 PM
I don't know why the error but you can do it different:
The Dynamic Pixels Per Unit sets the Quality for UI so you just got to have a variable to the Canvas Scaler and use CanvasScaler.dynamicPixelsPerUnit to change it
!WARNING! dont put it higher than 5, Lets just say that its not worth it
Your answer
![](https://koobas.hobune.stream/wayback/20220612051252im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Quality Menu Not working 1 Answer
Defining mipmap size minimum? 0 Answers
Post Build Low Quality Issue 0 Answers
How to retrieve quality settings of a specified QualityLevel? 0 Answers