Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: coolaneasy on September 25, 2014, 03:51:02 PM

Title: What can I do to figure out if the mouse cursor is inside my widget?
Post by: coolaneasy on September 25, 2014, 03:51:02 PM
Hi guys
I basically am going to be getting a callback upon which I want to know whether its within my widget bounds or not.
I did GUIMath.ScreenToPixels (UICamera.lastTouchPosition,alphaPanel.transform)
I guess the numbers this returns could be checked against the widgets pixel width and height but I can't seem to find a way to get that.
Thoughts?
Help appreciated.
Thanks
Title: Re: What can I do to figure out if the mouse cursor is inside my widget?
Post by: jeldrez on September 25, 2014, 04:04:04 PM
You can add a collider to your widget and activate the Debug option in the UI camera.
Title: Re: What can I do to figure out if the mouse cursor is inside my widget?
Post by: coolaneasy on September 25, 2014, 07:20:18 PM
I meant through code. I'll be having multiple colliders on top of this base collider and hence I can't rely on the mouseout callbacks from the base collider alone.
Title: Re: What can I do to figure out if the mouse cursor is inside my widget?
Post by: ArenMook on September 25, 2014, 07:53:21 PM
http://www.tasharen.com/forum/index.php?topic=11263.0
Title: Re: What can I do to figure out if the mouse cursor is inside my widget?
Post by: coolaneasy on September 26, 2014, 09:38:23 PM
I actually ended up using the ScreenToPixels and the localCorners on the widget. Seems to work fine so far. The screen to world to local wasn't giving me correct results for some reason(I was passing in the same camera for world and ui. wonder if it was something to do with that).