Hi every one, I started a mini project on Unity 3D and encounter this weird situation, when I use the Contains function and the GUI.Button to get the mouse over a button this happens:
The Rect to use with the Contains function is set using this coordinates and size (0, 0, 128, 64), when I test the function the Rect is on the bottom left and the GUI.Button is on the top left, here is the code.
var rect : Rect = Rect(0, 0, 128, 64);
function OnGUI() {
if (rect.Contains(Input.mousePosition)) {
print("Its over me");
} else {
print("Its out");
}
GUI.Button(rect, "Button");
}
So please any one can explain me why is this difference or it's a kind of bug in the program, also when I use the GUI.matrix = Matrix4x4.TRS() to scale the GUI about the screen size, the GUI.Button conserve the position but the rect move away from the button, for your attention thank you very much.