- Home /
Question by
mrawesome4212 · Dec 17, 2013 at 10:25 PM ·
guierrorbuttongui button
error with unity button unityengine.rect does t contain 5 contru
so in my code i am getting an error when making this button:
for(int y=0; y<hostData.Length;y++) {
if(GUI.Button(new Rect(Screen.width / 2, 65f + 30f * y, 30f, 300f, hostData[y].gameName))) {
}
please help
Comment
Best Answer
Answer by Bunny83 · Dec 17, 2013 at 10:32 PM
*sigh*
if(GUI.Button(new Rect(Screen.width / 2, 65f + 30f * y, 30f, 300f), hostData[y].gameName)) {
/|\ /|\
| |
Add bracket remove 1 bracket
Answer by Graham-Dunnett · Dec 17, 2013 at 10:29 PM
The button you create needs a rectangle to tell it where on the screen you want it, and the width and height of the button. So, that's 4 pieces of data (x, y, width, height). However, in your code you are giving the rectangle a fifth parameter, hostData[y].gameName
which is not needed. So, the compiler is telling you that this 5th value indicates you have made a mistake.
To fix your mistake, simply move one of your closing brackets after the 300f
.
Your answer
Follow this Question
Related Questions
how to use Gui.Buttons and keyboard ? 1 Answer
Button is not a member of GUI? 2 Answers
GUILayout Window Help 1 Answer