In my android game, for controls I have two joysticks and a GUI.Button in the middle, with ample space between all three.
The problem I’ve encountered is while a joystick is being moved, the button won’t work.
In contrast, when I tap both joysticks at once, the button activates without the touch being anywhere near it.
Any suggestions or advice on how to fix this would be greatly appreciated.
Thank you!
Ouss
January 25, 2014, 10:49pm
2
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))){
//your code to execture
}
}
}
}