when i click one button and popup a window, but if i click the position that the button stays on the window, the button is activated by the click, how to prevent the click throughout the window? thanks
In my project we searched all over forums and google and the only way we found to do this is to creat a dead zone. A dead zone is a zone where your mouse clicks won’t work in the game but will work on the gui
var guiArea : Rect = new Rect( 0, 0, 200, 100);
function OnGUI()
{
if(GUI.Button( guiArea, “Hello”))
{
Debug.Log(“Clicked the Button!”);
}
}
function Update()
{
// Accept mouse input for game loop
if(Input.GetMouseButtonDown(0) && !new Rect(guiArea.x, (Screen.height - guiArea.height), 200, 100).Contains(Input.mousePosition))
{
Debug.Log(“Clicked outside the button”);
}
}
thank you for your answer, but in one project, maybe include many different shapes, and it is too troublesome to do dead zone, any other ideals?