Hey guys, I’ve been trying to figure out how block clicks in my game scene with UI objects, but I’m running into problems.
I’ve set up this little debug code here
if( Input.GetMouseButtonDown(0) )
{
if(EventSystem.current.IsPointerOverGameObject())
{
Debug.Log ("Clicked on UI");
}
else
{
Debug.Log ("Clicked on Space");
}
}
This is running in the update function, and whenever I click in the game scene, even when it’s not over the UI, unity returns “Clicked on UI”. I have a UI Canvas that covers the entire screen, and an inactive UI Panel
that covers the game screen, but I have a CanvasGroup
on that panel with Interactable and Blocks Raycasts
set to false
when it’s deactivated.
If anyone can help me understand why IsPointerOverGameObject
is always returning true
I’d greatly appreciate it.
[72481-living.png|72481] The image file it's pulling from is this.
– Kristelkristen