I’m not sure if I misunderstood something, but consider this test:
Rect tstRct = new Rect(1, 1, 3, 4);
Debug.Log("Test rect (x, y, xMax, yMax): " + tstRct.xMin + ", " + tstRct.yMin + ", " + tstRct.xMax + ", " + tstRct.yMax);
Vector2 tstVec0 = new Vector2(0, 0);
Vector2 tstVec1 = new Vector2(1, 1);
Vector2 tstVec2 = new Vector2(2, 2);
Vector3 tstVec3 = new Vector2(3, 3);
Vector3 tstVec4 = new Vector2(4, 4);
Vector3 tstVec5 = new Vector2(3, 5);
Debug.Log("Vec0 in Rect: " + tstRct.Contains(tstVec0));
Debug.Log("Vec1 in Rect: " + tstRct.Contains(tstVec1));
Debug.Log("Vec2 in Rect: " + tstRct.Contains(tstVec2));
Debug.Log("Vec3 in Rect: " + tstRct.Contains(tstVec3));
Debug.Log("Vec4 in Rect: " + tstRct.Contains(tstVec4));
Debug.Log("Vec5 in Rect: " + tstRct.Contains(tstVec5));
Debug.Log("Vec contains Vector2(xMax, yMax): " + tstRct.Contains(new Vector2(tstRct.xMax, tstRct.yMax)));
The last line is testing if a rectangle contains it’s own (xMax, yMax) in it. Shouldn’t it return true? Since it is its maximum values afterall… Instead I get these results in Unity debug log:
Test rect (x, y, xMax, yMax): 1, 1, 4, 5
Vec0 in Rect: False
Vec1 in Rect: True
Vec2 in Rect: True
Vec3 in Rect: True
Vec4 in Rect: False
Vec5 in Rect: False
Vec contains Vector2(xMax, yMax): False
To make it easier to think about. Here is a graphical representation of the rectangle with a few extra markings:

Each square represents a pixel and coordinates are marked on the sides. Green area represents area of the rectangle and red numbers within the grid correspond numbers in Vector2 objects used by the test (0-5). Red square marks the coordinates of (xMax, yMax). I guess my question is… Why are xMax and yMax values outside the rectangle? Shouldn’t xMax in this case be 3 and yMax 4? If it’s like this by design, could someone help me understand why?
