How do i place the GUI so it looks like a inventory?

for(var z = 0; z < MainInventory.Count; z++)
{
if(GUI.Button(Rect(Screen.width/2, Screen.height/2 + (50 * z), 50, 50), GUIContent(MainInventory[z].Icon, MainInventory[z].Name + "
" + “Sell for " + MainInventory[z].Value + " coins”)))
{
Coins += MainInventory[z].Value;
MainInventory.RemoveAt(z);
}
GUI.Label(Rect(Screen.width/2 + 150, Screen.height/2 + (50 * z), 300, 300), GUI.tooltip);
}

Looks like this:

[Item]

[Item]

[Item]

I want it to be like this:

[Item] [Item] [Item]

[Item] [Item] [Item]

[Item] [Item] [Item]

[Item] [Item] [Item]

Do yourself a favor:

Very optimized solution.

using UnityEngine;

public class Example : MonoBehaviour {
    
    private byte WIDTH = 3;
    private byte HEIGHT = 5;
    
    private byte render_h = 0;
    private byte render_w = 0;
    
    private Rect slot = new Rect(0,0,32,32);

    private void OnGUI(){    
        render_h = 0;
        slot.y = 0;
        
        for(; render_h < HEIGHT; render_h++){
            render_w = 0;

            for(; render_w < WIDTH; render_w++){
                GUI.Box(slot, string.Empty);
                
                slot.x += slot.width;
            }
            slot.x = 0;
            slot.y += slot.height;

        }
    }
}