Input.mousePosition returns the mouse position in screen space. The screen space has it’s origin at the bottom left corner. The GUI space has it’s origin at the top left corner. Your problem is that you mix the Input class with OnGUI. Inside OnGUI you have to work with the Event class:
void OnGUI()
{
Event e = Event.current;
Rect posButton = new Rect(100,100, 150, 30);
GUI.Box(posButton, "Button");
if (posButton.Contains(e.mousePosition))
{
Debug.Log("Hola Mundo");
}
}
If the red dashed square is where you want to put it, you will need to take into consideration the screen height minus distance from bottom. The placement of the rect is from the top left of the screen, not the bottom left.
Rect posButton = new Rect(100,Screen.height - 100, 150, 30);
GUI.Box(posButton, "Button");
if (posButton.Contains(Input.mousePosition))
{
Debug.Log("Hola Mundo");
}