x


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?

more ▼

asked Nov 06 '09 at 04:21 PM

GameLvr gravatar image

GameLvr
150 12 14 19

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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)

more ▼

answered Nov 07 '09 at 11:20 AM

Aras gravatar image

Aras ♦♦
1.6k 7 26

(comments are locked)
10|3000 characters needed characters left

An alternative is to use the OnMouseOver callback (but it's not available on the iPhone, I believe)

more ▼

answered Nov 07 '09 at 11:24 PM

technicat gravatar image

technicat
1.5k 10 11 34

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3815

asked: Nov 06 '09 at 04:21 PM

Seen: 2988 times

Last Updated: Nov 06 '09 at 04:21 PM