i have an interface with various buttons and stuff but my mouse serve other functions in game, which i want to disable if the click happens on ui elements
how can i check if mouse is clicking on empty space?
i have an interface with various buttons and stuff but my mouse serve other functions in game, which i want to disable if the click happens on ui elements
how can i check if mouse is clicking on empty space?
Like this
eventSys = GameObject.Find("EventSystem").GetComponent<EventSystem>();
public void OnMouseDown()
{
if (eventSys.IsPointerOverGameObject())
{
return; // exit out of OnMouseDown() because its over the uGUI
}
// Do stuff here
}
it works but it also screws some other collision…
any reason why only this code alone could make things that are thousand miles apart collide?
The only thing that happens here is a check to see if the mouse is over the uGUI.
It must be the way you worked it into your code.
I just used OnMouseDown() as an example, you would need to put the if() in the locations that makes sense to your program.
yeah i didnt use on mouse down i just put the if, anyway i remade all and it works without that “bug” but it was really wierd i had objects colliding from very far away dunno, not anymore luckily
Programming can be mysterious sometimes, good luck!
Man, I love you right now. This also works with UI Toolkit.