Rect Constructor / .Contains - API mismatch?

I’m probably just missing something here, but there seems to be some mismatch with the Rect constructor and Contains function.

The constructor has you define the left, top, width and height.
However, when contains is called, it treats the top as the bottom.

Here’s a simple C# test:

Vector2 testPoint = new Vector2(0.5f, 0.5f);
		
// new Rect(left, top, width, height) ?

// should define space between (0,1) and (1,0), and contain (0.5,0.5)
Rect topDefinedRect = new Rect(0,1,1,1);    
if (topDefinedRect.Contains(testPoint))
    print ("point within topDefinedRect");   

// should define space between (0,0) and (1,-1) , and not contain (0.5,0.5)
Rect bottomDefinedRect = new Rect(0,0,1,1);
if (bottomDefinedRect.Contains(testPoint))
    print ("point within bottomDefinedRect");

And the resulting output:

Maybe I’m just missing something really obvious?

Rect(0,1,1,1) is between (0,1) and (1,2), not (1,0). Likewise, (0,0,1,1) is between (0,0) and (1,1), not (1,-1).

–Eric

Then isn’t the second parameter of Rect(x,y,w,h) the bottom of the rectangle, and not the top?

It depends on which coordinate system you’re using.

–Eric

I have been bitten by this as well.
I argue that for most practical circumstances it would be more helpful to name the second parameter bottom.

I guess ultimately the confusion stems from Unity´s more intuitive but somewhat non-standard way of handling 2D coordinate systems (input and 2D screen pos)