- Home /
Making this in the top right corner? (GUI)
How can i make this in the top right corner?
var names = QualitySettings.names;
for (var i = 0; i < names.Length; i++)
{
if (GUILayout.Button (names[i]))
QualitySettings.SetQualityLevel (i, true);
}
Answer by Fornoreason1000 · May 01, 2013 at 05:55 PM
Im assuming you talking about the button (; do you know about Layout areas? well you will need them in this case because your using a loop. define them in the loop so that the Y coordinate increases each loop. so they will not draw over each other. set the areas x pos to Screen width - button width to make in the right, and y to 0 + i * (insert you height here) to make the list go downwards. the width and height of the buttons is up to you.
for more info read this: http://docs.unity3d.com/Documentation/Components/gui-Layout.html
var names;
function Awake() {
names = QualitySettings.names;
}
function OnGUI() {
for (var i = 0; i < names.Length; i++) {
GUILayout.BeginArea(Rect(Screen.width - 130, 0 + 20 * i, 120, 30));
if (GUILayout.Button(names[i])) {
QualitySettings.SetQualityLevel(i, true);
}
GUILayout.EndArea();
}
}
Got some errors: get_names 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, ins$$anonymous$$d move initialization code to the Awake or Start function.
And
ArgumentException: get_names 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, ins$$anonymous$$d move initialization code to the Awake or Start function. Settings..ctor () (at Assets/$$anonymous$$yThings/$$anonymous$$yScripts/Settings.js:1)
yeah... QualitySettings.names is one of those function you have to call in Awake or Start(), I forgot to put that in, I've edited it now
Your answer
Follow this Question
Related Questions
GUI Texture on bottom left/right corners 3 Answers
What should I do for my Toolbar to work properly? 0 Answers
How can I set a GUI.box` align point? 1 Answer
Texture quality and quality settings 1 Answer