- Home /
Question by
NutellaDaddy · May 14, 2014 at 02:22 AM ·
c#guifor loop
How to make spaces in between Gui boxes being made in for loops?
I have a for loop that generates rows of GUI ,but I don't seem to know how to make the boxes have spaces in between them. Anyone have an idea of how to do this?
Here it is
cols is the number of columns and buttonsize is the size of the buttons
for(int x = 0; x < inventorySpaces; x++)
{
//EMPTY INVENTORY SLOTS
GUI.Box(new Rect((x % cols) * buttonSize , (int)x / cols * buttonSize,buttonSize, buttonSize), string.Empty, buttonStyle);
}
Comment
Best Answer
Answer by Bunny83 · May 14, 2014 at 03:06 AM
Well, instead of x*buttonSize and y*buttonSize you just do
x*(buttonSize+hspace)
and
y*(buttonSize+vspace)
(That's kind of elementary school math ;))
I feel dumb. $$anonymous$$y original one wasn't working because I didn't use the parenthesis. Thanks Bunny83!