Author Topic: UICamera Threshold doesn't work in 3.5.7  (Read 3210 times)

Laumania

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
UICamera Threshold doesn't work in 3.5.7
« on: April 13, 2014, 04:21:25 PM »
Hi

I'm a happy NGUI user, but discovered a bug today after upgrading to 3.5.7 (Apr 12, 2014).

After the update, I saw that this threshold for Mouse Drag/Tap and Touch Drag/Tap isn't really working anymore. I have set them up to like 1500, which normally gives me the ability for touch a button and even though the users finger move pretty far from the button, it still trigger a OnClick.

That doesn't work anymore.

Is it a bug or am I missing something in this new version? It use to work perfectly and I haven't changed anything related to this as far as I know.

Thanks in advance,
Mads

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera Threshold doesn't work in 3.5.7
« Reply #1 on: April 14, 2014, 03:01:07 AM »
This hasn't changed in some time. The last related change was making it use the sqrMagnitude instead of magnitude, removing the need for a square root operation. Try adding a Debug.Log around line 1455 where it sets:
  1.                                         // We've dragged far enough to cancel the click
  2.                                         currentTouch.clickNotification = ClickNotification.None;

Laumania

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UICamera Threshold doesn't work in 3.5.7
« Reply #2 on: April 15, 2014, 12:55:52 PM »
Ok thanks for pointing me in the right direction. I found the bug.

Around line: 1501
  1. if (currentTouch.clickNotification != ClickNotification.None && currentTouch.pressed == currentTouch.current)

The last part is the one introducing the bug, as it validate to false if you move away from the currently clicked button, and thereby make the threshold useless.

So I fixed it very simply by changing it to:
  1. if (currentTouch.clickNotification != ClickNotification.None)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera Threshold doesn't work in 3.5.7
« Reply #3 on: April 16, 2014, 10:13:15 AM »
That code is intentional, as releasing the touch on a different object should not result in a click. It would be wrong behaviour if it did.

Laumania

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UICamera Threshold doesn't work in 3.5.7
« Reply #4 on: April 16, 2014, 12:59:17 PM »
Well...depends what you need and as stated, it worked like that in the previous version.

In my game the player needs to hit some relatively small buttons very fast. This result in the players finger slider off the button, pretty often actually, which then cancels the click and the player dies. Players gets frustrated and that's not what I want.

So I need the threshold to go beyond the boundaries of the button. Not because they need to be able to drag their fingers half a screen away and still click, but because they slip off the edge of the button.

So I won't say it's a "wrong" behavior. As I understood it initially, the threshold was exactly there to give the users of NGUI the ability to have both the behavior I want and the one you want.

But it's up to you, I know how to make it work like I want now :)

Thanks for you quick replies.