stacking items next to each other

Ok so the way i’ve set this loot system up is whenever a new item enters the inventory a button is created, and when it is
clicked the item is removed.

The problem is they are stacking on top of each other. I would like them to stack next to each other.

InventoryGUI.js:

function OnGUI () {

   GUI.Box( Rect(280, 0, 200, 320), backDrop);
   
   GUI.Box( Rect(280, 300, 200, 20), copperTexture + totalCopper + "c");
   
for (var i : Transform in UpdatedList) {

   var item = i.GetComponent(Item);
   
if (GUI.Button( Rect(280, 0, 50, 50), item.inventoryIcon)) {

   associatedInventory.RemoveItem(i);
   
   item.Drop();
   
   lastUpdate = 0.0;
   
}

}

}

You are stacking all the buttons to the same GUI coordinates. Try keeping a counter on how many items you have and use that to increment the X- or Y-position of the button:

if (GUI.Button( Rect(280+(itemCount*buttonWidth), 0, 50, 50), item.inventoryIcon)) {

   associatedInventory.RemoveItem(i);

   item.Drop();

   lastUpdate = 0.0;

}