- Home /
Need ICanvasRaycastFilter for physics raycasts
The ICanvasRaycastFilter interface only seems to work for GraphicRaycast events.
How can I implement something like this for physics raycasts?
The goal is to have my component's IPointerEnterHandler.OnPointerEnter function invoked, ONLY under certain conditions (I check the hit point's texture-alpha). I was hoping I could check these conditions inside the ICanvasRaycastFilter interface's IsRaycastLocationValid function, but it appears I cannot because:
I'm using box colliders and mesh colliders, and they are not on a canvas. My Camera has a PhysicsRaycaster (not a GraphicRaycaster) component.
Alternatively: If I can somehow "abort and undo" the state of PointerEnter , inside OnPointerEnter, (so that OnPointerEnter will be called again next frame) that would work to.
Another alternative: If I can add another component to the gameObject, and have all events go through that first, I think I can USE() the event so that it won't propagate to my other component. But I don't know if I can ensure they always go to that component FIRST.
Your answer
![](https://koobas.hobune.stream/wayback/20220612143634im_/https://answers.unity.com/themes/thub/images/avi.jpg)