Support => NGUI 3 Support => Topic started by: jaz1974 on September 23, 2013, 04:03:45 AM
Title: 'Long Press' functionality in NGUI?
Post by: jaz1974 on September 23, 2013, 04:03:45 AM
Hi,
Anyone know if there is a way of determining when the user has pressed on a button for more than a specific duration? I'm trying to figure out how I can make something draggable if its been pressed on for more than 1 sec. Any advice is greatly appreciated.
Cheers!
Jaz
Title: Re: 'Long Press' functionality in NGUI?
Post by: ArenMook on September 23, 2013, 07:07:44 AM
Record the time in OnPress(true), clear it in OnPress(false), check the duration in Update.
Title: Re: 'Long Press' functionality in NGUI?
Post by: jaz1974 on September 23, 2013, 07:24:25 AM
Hey ArenMook,
Thanks for the info. Whilst I was waiting I'd created something using 'Time.fixedTime'. Is this similar to your suggestion? Perhaps the OnPress(true/false) is more efficient? Here's the code I created : #pragma strict
var timeCurrent : float; var timeAtButtonDown : float ; var timeAtButtonUp : float ; var timeButtonHeld : float = 0 ; var draggable : boolean = false;