Rect with a height of 0 has a non-zero height

I’m drawing a box on the gui with this function:

void DrawQuad(Rect position, Color color) {
	texture.SetPixel(0,0,color);
	texture.Apply();
	GUI.skin.box.normal.background = texture;
	GUI.Box(position, GUIContent.none);
}

When I call it with DrawQuad(new Rect(10f, Screen.height - 48f, 10f, 0f), ColorPalette._yellow);
It draws a square like this:

107924-square1.png

Note that the Rect’s height is 0.

Through trial and error the thinnest I can get it is when I put the height to around 5.8f, but even then it’s not super thin:
107925-square2.png

Why is the flattest box only when I put the Rect height at 5.8 (instead of 0)? This is pretty counterintuitive. Is there any way to make the box 1 pixel high? (essentially a line)

You use the default box style. It has some margin, padding as well as a border. The border is most likely your problem. When you use a rect with height 0 the border will actually overlap on the wrong side.

You may want to have a look at my IMGUI crash course as well as the official documentation