Unity Rect.Contains won't return true?

I’m attempting to create a few zones on my UI (4.6) where the user is able to touch but it will not effect in game events.

My solution to this was to create two Rect objects that basically covered my UI buttons. The problem is my code NEVER returns true and I am not sure why.

I’m running on an Android tablet and I’ve debugged the touch events to determine where the Rect’s need to be placed. (I am developing for one device so I can safely hard code some values if I need).

I then test my input against that Rect and it does not evaluate to true even though I can see (and test by simple math) that is should. I’ve placed some test code in my update loop to check the code and it does indeed not evaluate as I would expect, am I doing something wrong?

        Rect topLeft = new Rect(0, 1100, 630, 200);
        if (topLeft.Contains(new Vector2(250, 982))) {
            Debug.Log("It works");
        }

Clearly I’ve hard coded those values but they were an example touch input that I would have expected evaluated to true…

So you’ve set a rectange with minX = 0, maxX = 630, minY = 1100, maxY = 1300 and you expect x = 250, y = 982 to be inside that rectangle? Sorry to disappoint you but no that’s not gonna work because your y < minY.

If those numbers were just out of your head then provide the actual code representing the issue, if not then…well either be more attentive or start learning math.

So although Unity says that the X,Y co-ordinates are top left of the Rect for some reason mine are always being calculated from bottom left, therefore altering my code to below worked.

Rect topLeft = new Rect(0, 900, 630, 200);

Having said that I think I may be assuming from here because it doesn’t say that explicitly…