Author Topic: Problem with sliding across buttons  (Read 12410 times)

afroman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Problem with sliding across buttons
« on: December 04, 2013, 07:02:20 PM »
For some reason I can't get NGUI to process a new touch event when sliding across from a previous button.
After turning on debug, the camera reports a "touch hit" on the new button, but it doesn't process the event until the current event has been completed.
How would I get NGUI to process all buttons when sliding?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with sliding across buttons
« Reply #1 on: December 05, 2013, 03:12:19 PM »
You don't get touch events when you slide over objects. You Get OnDragOver / OnDragOut: http://www.tasharen.com/forum/index.php?topic=6711.0

afroman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Problem with sliding across buttons
« Reply #2 on: December 05, 2013, 03:52:31 PM »
Ok, seems things have changed a bit, OnDragOver / OnDragOut wasn't previous needed.
How would I reflect these changes with UIButton or UIButtonColor as they use to work?

Thanks in advance!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with sliding across buttons
« Reply #3 on: December 05, 2013, 04:02:26 PM »
I can just update the UIButton script to do it for the next release.

afroman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Problem with sliding across buttons
« Reply #4 on: December 06, 2013, 08:40:58 AM »
Alright nice, thanks!

afroman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Problem with sliding across buttons
« Reply #5 on: December 09, 2013, 06:42:55 PM »
Updated to NGUI 3.0.7 rc2, the problem has gotten slightly worse.
After dragging over a button, the button colour changes to the original colour and size instead of keeping the button pressed colour.
Also UIButton still has no effect when dragging over a new button.

I'm so picky about this because this is for the directional buttons in my game and the previous behaviour of it was great.
Any help or clue on how to restore the button behaviour would be great!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with sliding across buttons
« Reply #6 on: December 10, 2013, 01:05:48 AM »
That's the widely accepted behaviour in UI systems that people have been requesting. When you press on something then drag off, another button doesn't get pressed. Only if you drag over the original button will it get pressed again.

You should make a custom script in your case that listens to OnDragOver / OnDragOut in addition to OnPress and changes the color accordingly.

Litherad

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Problem with sliding across buttons
« Reply #7 on: December 13, 2013, 08:57:23 AM »
Hi

I have 2 buttons next to eachother. In the previous versions stickypress allowed me to slide my fingers from one button to another, just like an oldschool D-pad. Without stickypress this isn't possible without some custom workaround?
I only discovered it when the testgroup suddenly found the game harder to play because they had to lift their finger when changing direction. I tried playing around with the OnDrag events, but I could only replicate the old behaviour by having a dummyobject with a collider being dragged between the buttons.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with sliding across buttons
« Reply #8 on: December 13, 2013, 09:40:10 AM »
If you want to mimic the old sticky press behaviour, open UIButton and find these two functions:
  1.         protected override void OnDragOver ()
  2.         {
  3.                 if (isEnabled && UICamera.currentTouch.pressed == gameObject)
  4.                         base.OnDragOver();
  5.         }
  6.        
  7.         protected override void OnDragOut ()
  8.         {
  9.                 if (isEnabled && UICamera.currentTouch.pressed == gameObject)
  10.                         base.OnDragOut();
  11.         }
Change to:
  1.         protected override void OnDragOver ()
  2.         {
  3.                 if (isEnabled)
  4.                         base.OnDragOver();
  5.         }
  6.        
  7.         protected override void OnDragOut ()
  8.         {
  9.                 if (isEnabled)
  10.                         base.OnDragOut();
  11.         }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problem with sliding across buttons
« Reply #9 on: December 13, 2013, 09:53:49 AM »
P.S. This is also an option in the next release (specified on the UIButton).