- Home /
GUI.Button simple dropdown menu problem
I've made a very simple dropdown menu using GUI.Buttons, a for-loop and Arrays. But I can't get it to work, so I hope somebody here can tell me why this isn't working and how I can get it to work.
for(j=0;j<i;j++)
{
if(GUI.Button (new Rect (mousepos.x - 40, mousepos.y - 25 +(j*25), 80, 20), buttonname[j]))
//Stuff I want to do
}
yes i is set and it is working so far as I can see the buttons and they are on the right position and have the right text. But I don't get any response when klicking them. If I don't make the buttons by a for-loop it works, but i need a loop because the number of options (i) is changing.
Well for one, you have the buttons all doing the same thing. Second, you don't need the (new when it's an if statement.
I know this is old but if your coding in c# you do need the new Rect in the if statments for it to work.
Your answer
Follow this Question
Related Questions
How Set a Rotation Of Child GameObject For Character Selection 0 Answers
Transform translate speed of paddle depending on mouse speed 1 Answer
CS1519 C# error `void'? 1 Answer
Easy C# Question 1 Answer
Help with Unity 3D animator (3D game) 0 Answers