- Home /
GUITexture buttons in Android are too sensitive
I am making an android game. I use GUITexture to make buttons. But for some of the buttons, when it is tested on an Android phone using apk file, the button pushed make another button in same position in the next scene or another button which will transform to the same position pushed. I use System.Threading.Thread.Sleep to make some delay to prevent this but some doesn't work especially for the buttons which will transform. How can I solve this problem?
Your question is confusing. You want after pressing the button1 button2 appear? But button2 should appear in the next scene, after a load.level in the same position of the button1?
@$$anonymous$$amuiyshirou button2 is in the same scene with button1 but its position is (1000, 1000, 0). button1 is (0, 0, 0). After pushing button1, button2 will change to (0, 0, 0) and button1 will change to (1000, 1000, 0).
Answer by perchik · May 01, 2014 at 06:17 PM
Perhaps you should do your changes when the button is unpressed. For example, getting key events, Input.GetKeyDown fires when the button is pressed down, Input.GetKeyUp fires when the key is released. I think you need to implement something similar for your buttons.
To implement this, it seems like having two boolean flags should work:
//pseudocode:
Start{
btnWasPressed=false
btnPressed=false
}
OnGUI{
if(btn)
{
btnPressed= true
}
if(wasBtnPressed && !btnPressed)
{
//change buttons
}
wasBtnPressed = btnPressed
}
That way, wasBtnPressed tells you if the button was down last frame. If it was down last frame, but not this frame, then the button has been released.