- Home /
GUI.Button not working fine on iphone when i press one button the other do not pressed
GUI.Button not working fine on iphone when i press one button the other do not pressed i.e in my game there is a joystick to control the car and there is a button to fire when i control my car using joystick and in mean time try to fire the button not pressed as i release the joy stick the button is pressed and iphone is multi touch so please tell me how to solve it :)
Could you post (maybe a simplified, stripped down) version of the code your are using to detect the joystick and the GUI.Button push?
Hi Sure i use the built in joy stick in unity 3D .. but joy stik doesn't matter but the simple unity 3D buttons like GUI.Button(Rect(10,90,Screen.width/6,40), "Resume") does not work properly i.e i pressed one button and in mean time trying to press second button but it do not work until i release the first button ..!!
Ah ok, I get what you wanted now, but Unity's OnGUI (unless it recently changed) is not multi-touch compatible. It's purely monotouch.
Answer by Ouss · Jan 25, 2014 at 10:53 PM
Hi, In order to make the button clickable while moving with the joystick/or using another button 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
}
}
}
}