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…