- Home /
Text do action when clicked
I want it to change quality when you click on text, not GUI. How would I do this?
This is a script for clicking on GUI
function OnGUI () {
// Make a background box GUI.Box (Rect (10,10,200,1000), "Graphics Resolution");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if (GUI.Button (Rect (20,40,80,20), "Fastest")) {
QualitySettings.currentLevel = QualityLevel.Fastest;
}
// Make the second button.
if (GUI.Button (Rect (20,70,80,20), "Fast")) {
QualitySettings.currentLevel = QualityLevel.Fast;
}
// Make the second button.
if (GUI.Button (Rect (20,100,80,20), "Simple")) {
QualitySettings.currentLevel = QualityLevel.Simple;
}
// Make the second button.
if (GUI.Button (Rect (20,130,80,20), "Good")) {
QualitySettings.currentLevel = QualityLevel.Good;
}
// Make the second button.
if (GUI.Button (Rect (20,160,80,20), "Beautiful")) {
QualitySettings.currentLevel = QualityLevel.Beautiful;
}
// Make the second button.
if (GUI.Button (Rect (20,190,80,20), "Fantastic")) {
QualitySettings.currentLevel = QualityLevel.Fantastic;
}
}
if you know the rect that is pretty simple but don't expect us to solve your problems 1. you don't accept answers or post too hard questions and your reputation is too low
to raise your karma and post good questions: Unity Answers Tutorial
so I'm going to make a general direction IF mouse position is inside your rect than do what ever you must
for doing that you need 4 boolian statements inside if statement
OR 4 if statements so Up, Down, Left, Right
do some research and I might help
if it'll be off topic post a new Q and close this one
Answer by iwaldrop · Apr 02, 2013 at 09:26 PM
You want to look at QualitySettings.SetQualityLevel() and QualitySettings.names.
You'd either want to create as many buttons as you have quality levels or you'd want to hardcode some specific choices.
Once you know what quality level index you want to use, simply pass that integer to QualitySettings.SetQualityLevel(), like so:
if (GUI.Button(new Rect(20,20,80,20), QualitySettings.names[0]))
QualitySettings.SetQualityLevel(0);
but you forgot you cannot press a button IF the label is over a button
tho I know you could make text inside a button but still he wants label to be pressed