- Home /
GUI.Button won't work while Joystick is being moved.
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!
Answer by Ouss · Jan 25, 2014 at 10:49 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))){
//your code to execture
}
}
}
}
Your answer
Follow this Question
Related Questions
How to Fire a projectile using the right Thumbstick? 2 Answers
Andriod Multitouch with joystick 1 Answer
Camera Facing Forward on Android 0 Answers
GUI Joystick 1 Answer
help, 3d android game joystick 1 Answer