Hi all, when I click in my project it performs a raycast and returns the object that is encountered and performs a function, except when I click on a UI button, it doesn’t as the UI element “blocks” the raycast. This is desired behavior, so, so far so good.
The issue that I’m coming up against is this only happens when I click with my mouse. I’m building for a mobile platform, and when I test on a touchscreen and tap on a button the button works as expected except the raycast is not “blocked”. is there a reason that touch and click would be treated differently in this context? FWIW, my script uses the code below in update to listen to both touch and click:
if (EventSystem.current.IsPointerOverGameObject())
{
//THIS CODE RUNS
return;
}
if (Input.touchCount > 0)
{
if (EventSystem.current.IsPointerOverGameObject(Input.touches[0].fingerId))
{
//THIS CODE DOSN'T RUN :(
return;
}
}