Event System Panel Raycaster Causing OnPointerEnter to not work. (2D URP)

Hi there,

I’ve been working with the new UIToolkit and Input System on my latest project. I’ve implemented a UI and the Input System seems to be working great.

However, on a new feature I’m trying to implement, I want some code to execute when I hover over a gameobject. I’ve kept it simple for now, just displaying a debug message. I’m using IPointerEnterHandler and IPointerExit Handler (and their neccessary functions).

I set up the 2D Raycaster on my Main Camera, a 2D collider on the item I’d like to hover over (and attached the hover functionality script to it). I wasn’t able to see the debug messages when hoving over the GameObject though.

After many hours of experimentation. I’m able to get the mouse hovering debug messages to show if I disable the “Panel Raycaster” that appears in a child element of my EventSystem in play mode. This will then cause my UI elements to not be detected by the mouse.

Is there a better solution to toggling the Panel Raycaster on and off? That would be fine if I was hitting a button to toggle a menu, but what about a persistant UI element, like an item hotbar? I’d need to enable the panel raycaster when I am hovering over it, but to detect that… I’d need to use the panel raycaster??

Any help here would be very much appreciated. Thanks for your time!

Hello,

After a week of building a workaround, I’ve figured out the issue.
I had a few VisualElements that covered the entire screen but were transparent (parent elements), and so the mouse was not detecting the game object below them.

By changing the Picking Mode to “Ignore” on these elements, the IPointerEventHandler then registered.

Hope this helps anyone that felt as desperate as I :slight_smile: