- Home /
Possible to use sprite mesh for UI.Image GraphicRaycaster culling?
I'd like to use a generated sprite mesh as part of the IsRaycastLocationValid culling for UI Images on a Canvas. After looking through the UI source code, it doesn't appear that the sprite mesh is respected in any way by the Image class - it seems to only be used for 2D game stuff, not for UI.
Are there any helper scripts that have been created to check the sprite mesh against the raycast location, so you can cull input events that are within the Image rect but outside the sprite mesh?
I think this would be a nice feature for Unity to implement...
Answer by henryherkula · Mar 02 at 06:06 PM
Steve Streeting wrote a component which you can use on your image game object to check if you are inside the custom outline of the sprite. But be careful: You should check the positions of the triangles, if you use a perspective camera.
https://twitter.com/stevestreeting/status/1205526159959703552
https://gist.github.com/sinbad/7c21ee7a15f5502399c8253223e2d70a