Author Topic: What can I do to figure out if the mouse cursor is inside my widget?  (Read 2232 times)

coolaneasy

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 34
    • View Profile
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

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: What can I do to figure out if the mouse cursor is inside my widget?
« Reply #1 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.

coolaneasy

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: What can I do to figure out if the mouse cursor is inside my widget?
« Reply #2 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

coolaneasy

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: What can I do to figure out if the mouse cursor is inside my widget?
« Reply #4 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).