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;

}

}

}

2 Answers

2

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.

yield WaitForSeconds (0.5f);

Type this line where you want a delay.