- Home /
help with touch button (android)
hi i was wondering if anyone could help me i want it so i can hold down the button and then the amount of times the button will contiunuestly go up every 0.5 seconds please note this will end up being a d pad for a game. #pragma strict
var HI : Texture2D;
var touchcount = 0;
function Update ()
{
if (Input.touchCount == 1)
{
var currentTouch: Touch = Input.touches[0];
if(currentTouch.phase == TouchPhase.Began && guiTexture.HitTest(currentTouch.position))
{
//stuff happens hear
touchcount ++;
guiText.text = "Amount of times its been presed:"+ touchcount;
}
}
}
Answer by TheBlitheringIdiot · Jan 25, 2012 at 07:44 AM
Not sure exactly what you're after, but you have a massive problem as far as I can see. The second if statement, checking if you are pressing, is within the first if statement, which only returns true if you've already pressed once. But it will never registre the first touch because you'll never get up to touchcount == 1.
Answer by hypnoticmeteor · Jan 08, 2015 at 07:25 PM
yield WaitForSeconds (0.5f);
Type this line where you want a delay.
Your answer
Follow this Question
Related Questions
Button Focus Prevents Touch Raycast (Android C#) 1 Answer
How to make this buttons for Android? 1 Answer
Touch Button android 2 Answers
Why this simple code doesnt work? 0 Answers
Touch Button animation 0 Answers