Support => NGUI 3 Support => Topic started by: beforethelight on July 18, 2013, 05:21:59 PM
Title: Button 'Sticks' when released
Post by: beforethelight on July 18, 2013, 05:21:59 PM
I have been searching for some help on this for a while but cannot fix it myself or find any information so here is my issue. On some (Android)devices my buttons when pressed then released hang in the pressed position for a second or so after release. My code is below. For this example it is a gas pedal for a car and when you release it and it doesn't stop accelerating it becomes a problem quick. I have run this in FixedUpdate as well as Update with no change. I have a similar issue with my space lander game buttons sticking. Any help would be greatly appreciated. Thanks
#pragma strict
var release :String;
var go : boolean;
var drive : Drive;
function OnPress (isPressed : boolean){
if(enabled){
go = isPressed;
if(!isPressed){
OnRelease();
}
}
}
function FixedUpdate(){
if(!go){
return;
}else{
drive.Accelerate();
}
}
function OnRelease(){
drive.Released();
}
function OnDisable(){
if(!go){
return;
}
go =false;
drive.Released();
}
Title: Re: Button 'Sticks' when released
Post by: ArenMook on July 19, 2013, 01:50:55 AM
NGUI events are sent in LateUpdate, which happens every frame, while physics updates (FixedUpdate) occurs every so often -- by default 20 times per second, although I don't know what it's set to in your Physics settings. Certainly nothing in NGUI would cause the state to "hang" for a second or two.