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?
asked Mar 24 '12 at 05:37 PM
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 :
answered Mar 24 '12 at 05:47 PM
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 (
answered Mar 24 '12 at 05:48 PM