I’m not an expert on screen coordinates, but I believe in computing systems the screen origin (0,0) is always in the top-left corner of the screen. From that origin point, the coordinates at the very bottom of the screen and the very right of the screen are accounted for as being positive. This means that despite what you might think about normal coordinate geometry, as we go down the screen the y-coordinates become larger as opposed to becoming smaller as you assumed they should have.
Conversely, anything above what the maximum y coordinate of the screen is becomes negative and anything further to the left (x-axis) than the dimensions of the screen allow becomes negative. So, if your rectangle had coordinates of (-100, -100), it would be completely off the screen.
So, in fact, in this case (your rectangle being drawn at the origin point of the screen), the bottom coordinate should be positive 100 as Rect.yMax reveals.
I hope that made some element of sense … if not, hopefully I’ll be able to elaborate a bit better!
Klep
The origin depends on what coordinate system you're using. GUI space has 0,0 at the top-left, screen space has 0,0 at the bottom-left.
Exactly, but the Rect struct always act the same way. The rect actually stores m_XMin, m_YMin, m_Width and m_Height. Nothing more. All other properties are calculated out of these values. xMin and x just return m_XMin. xMax return m_XMin + m_Width. The difference in x and xMin is when you set them. x just sets directly m_XMin so m_Width stay the same. If you set xMin it will make sure that xMax will stay the same. Therefore m_Width is changed. Because Rect is used in may different cases they deprecated left, right, top and bottom because it's misleading.
The origin depends on what coordinate system you're using. GUI space has 0,0 at the top-left, screen space has 0,0 at the bottom-left.
– Eric5h5Exactly, but the Rect struct always act the same way. The rect actually stores m_XMin, m_YMin, m_Width and m_Height. Nothing more. All other properties are calculated out of these values. xMin and x just return m_XMin. xMax return m_XMin + m_Width. The difference in x and xMin is when you set them. x just sets directly m_XMin so m_Width stay the same. If you set xMin it will make sure that xMax will stay the same. Therefore m_Width is changed. Because Rect is used in may different cases they deprecated left, right, top and bottom because it's misleading.
– Bunny83I really don't think the unity documentation explains this well at all. That rect documentation with the yMax at the top is very misleading imho.
– demented_hedgehog