Author Topic: if(hoveredObject == null) doesn't work, it's UI Root if nothing is clicked  (Read 4619 times)

uberwleiss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Hello,

I've updated NGUI for my older game because of porting it to WP8 (the old version didn't work). I've updated NGUI to the latest version and using the version of Unity 4.6 RC2 Beta.

The problem is that "if(UICamera.hoveredObject == null)" doesn't work. When i debugged, to show which object is actually hovered when I click, it's always UI Root if I don't click any NGUI button.

I've worked around this by changing it to if(UICamera.hoveredObject == uiRoot) and it works now. But I wonder if this is the intended behaviour?

Thanks

uberwleiss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: if(hoveredObject == null) doesn't work, it's UI Root if nothing is clicked
« Reply #1 on: November 16, 2014, 08:03:04 AM »
OK, I've done the same with another project. Same problem.

What is the right way to prevent clicks/taps going through the buttons into the game?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: if(hoveredObject == null) doesn't work, it's UI Root if nothing is clicked
« Reply #2 on: November 17, 2014, 08:52:34 AM »
Change that statement to: if (UICamera.hoveredObject == UICamera.fallThrough)

P.S. Also note that there is UICamera.isOverUI.