- Home /
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.
Answer by yoyo · Apr 19, 2012 at 12:45 AM
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.
Your answer
Follow this Question
Related Questions
How to Limit Input.mousePosition or Raycast 1 Answer
Raycast2d not working C# :( 1 Answer
Checking if object stopped being hit by Raycast while overlapping another object of the same type. 0 Answers
Problem with raycasting in direction of mouse 0 Answers
How do I have the object disappear once the FPS controller looks at and then looks away. 0 Answers