Mouse Over Questions

Hey ladies and gents,

I was wondering if anyone had played around with detecting when a mouse is hovering over a plane that has a transparent texture applied and the cursor is over a part of that image that has a specific alpha value. My initial impression is that i would have to do a raycast and then detect the uv point on the texture from the point i contact on the plane and then check the alpha (0-1) value and then return true or false.

Has anyone seen this done or is there a better way to do this before i run forward with what ive thought may work.

I’ve implemented click-to-texture and retrieved a pixel through the texture coordinates, so it definitely works. You need to make the texture readable – click on the texture asset in the Project view, set the texture type to Advanced, and turn on Read/Write Enabled.

You can use Physics.Raycast and get the texture coordinate from the RaycastHit structure it returns.