Author Topic: 3.0.6 OnClick() last hit issue  (Read 5978 times)

Nezabyte

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 10
    • View Profile
3.0.6 OnClick() last hit issue
« on: November 25, 2013, 07:26:42 PM »
We upgraded to the latest version of NGUI, and for some reason the last hit is now "UI Root (2D)" despite the UICamera debugger saying the last hit was "Button_Spawn".

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.0.6 OnClick() last hit issue
« Reply #1 on: November 25, 2013, 07:30:49 PM »
LastHit is the result of a raycast hit, which in a UI hierarchy can be anything. UICamera.hoveredObject might be more accurate for you in this case.

Nezabyte

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: 3.0.6 OnClick() last hit issue
« Reply #2 on: November 25, 2013, 07:48:04 PM »
Was the way raycasts or the UI camera work for NGUI changed? I reverted back to 3.0.5, and the button is working normally again, but I'm not 100% sure if it's NGUI or some other code.

In any case, I'll try to upgrade again then try hoveredObject instead. Thanks for the tip.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.0.6 OnClick() last hit issue
« Reply #3 on: November 25, 2013, 07:55:06 PM »
It depends on your UICamera Event Type setting. If it's World, then it's based on colliders. If it's UI, then it's based on depth and lastHit may not match what actually gets the event.