I am having problems getting the new UI system to block raycasts on mobile devices.
This works 100% perfectly on desktop but does not work on touch screen devices.
I’ve tried adding a cube behind my UI elements to block raycasts, Canvas Groups with the blocks raycast option checked and while it all seems to work great on desktop I cannot get it to work the same way on mobile touch screen devices.
I should add I am using Navmesh and Navmesh agent to move my player object to the clicked location on the screen.
Has anyone come up with a solution for this?
You can activate the standalone Input Module on your EvenSystem on Mobile Devices. If you do this you might want to deactivate the Touch Input Module.
This will make “EventSystem.current.IsPointerOverGameObject()” work correctly.
(I haven’t tested extensively though, so there might be other side-effects)
I imagine you have found a solution. I had the same problem and what saved it for me is the following:
EventSystem.current.IsPointerOverGameObject() function takes an
ID for which pointer should be tested.
1 is the first finger,
2 is the second finger, etc.
By default, if you don’t specify any argument, it uses the mouse left click ID (-1), and doesn’t work on mobile devices
I hope this helps.
Charles, from Haze Games.