- Home /
What GUI Texture Object is the cursor over?
I know I can use Raycast to find what 3D object my cursor is over, but I also need to know if I am over a GUI Texture Object and if so, which one it is.
What do I need to use to return the GUI Texture object at Input.mousePosition?
Answer by Aras · Nov 07, 2009 at 11:20 AM
GUILayer.HitTest should help. Something like (attach to the camera):
var gui:GUILayer = GetComponent(GUILayer);
var element = gui.HitTest (Input.mousePosition);
if (element) {
// hit!
}
Or use OnMouseOver callback (this is not available on Unity iPhone though)
Answer by $$anonymous$$ · Nov 07, 2009 at 11:24 PM
An alternative is to use the OnMouseOver callback (but it's not available on the iPhone, I believe)
Your answer
Follow this Question
Related Questions
How will i get animated gif images in scene? 6 Answers
GUI.TextField problem, won't update var. 0 Answers
GUI.Label positioning for many device resolutions 1 Answer
dialog multi anglet 0 Answers
Disable Mouse Input when OnGUI() 1 Answer