In my project when I click on a UI button (screen space) the ray will be detected by the UI element AND on any objects behind it in world space. Example: clicking a move button automatically moves my agent to the position BEHIND the UI button. I wish it was as easy as just checking the raycast target box.
I have used EventSystems.OnPointerEnter and EventSytems.OnPointerExit to reveal and hide UI images and text but can’t quite put together a way to stop the ray when it hits the button.
Two separate rays? Perhaps one with a distance of 0 or 0.01? If so… How?
There are a lot of inconsistent hacks and poorly conceived work arounds for this; ranging from just won’t work to laugh out loud preposterous. What is consistent is that there is a whole crowd of people who are struggling with this issue.
Anybody want to show off some code magic?
PS. Code Magic is similar to Dance Magic but with less David Bowie.