- Home /
Why i cant press(use) joystick and gui button at the same time ????
im working with android and i use the joy stick to walk around and the guy button to shoot, but i cant do them both anyone know why
Comment
It seems like you don't have mul$$anonymous$$ch enabled. Check out Unity's Input manuals.
Answer by Ouss · Jan 25, 2014 at 10:37 PM
Hi, In order to make the button clickable while moving with the joystick you need to manage the multi touch with TouchCount in the Update(), here a sample:
void Update()
if(Input.touchCount > 0){
for(int i = 0;i<Input.touchCount;i++){
Touch touch = Input.GetTouch(i);
if(touch.phase == TouchPhase.Began && buttonRect.Contains(new Vector2( touch.position.x,Screen.height - touch.position.y))){ // or hitTest if it's a gui texture
//here you write the code you want to execute
}
}
} }