|
I'm trying to use a for loop to create a button for every item is found inside the list menuItems. However i also want each button to be 50 pixels away from the last button. To do this i add 50 pixels to the xPos of the button after each loop. the problem is that it keeps adding 50 to it every frame. Help?
(comments are locked)
|
|
You need to reset buttonPosX at the start of each OnGUI frame loop. For button spacing, you want to add the depth of the button with the space you want in-between. (I made the button depth 50) Try this to replace your current GUI function :
(comments are locked)
|
|
You're not resetting buttonPosX before the loop in OnGUI, so it will just keep adding to it forever. It would be better and simpler to use a standard for loop ( thx for the link , very useful info there :)
Mar 24 '12 at 05:54 PM
alucardj
thanks! although alucardj's solution works too.
Mar 24 '12 at 06:48 PM
Kag359six
im having an issue with the standard for loop. when i use it, all of a sudden its says that the there is no valid arguement for the gui.button line
Mar 24 '12 at 06:55 PM
Kag359six
try debugging to see where it's breaking. just guessing, you may be running out of places in the menuItems array. see the .length may be 12 , but counting from 0 , you get to 11. to fix this :
Mar 24 '12 at 07:35 PM
alucardj
(comments are locked)
|
