- Home /
Button does not work when another is active? iPhone
Hi,
I have a "fire" button,a very simple On GUI ... If(GUI.Button..., click bang! works well.
But I also have a joystick on the other side, that works via GUI texture iphone input touch.
while I am moving the character around with the joystick, the fire button does not register when I click it. only when I let go of the joystick can I fire.
any thoughts?
Answer by Eric5h5 · Sep 23, 2010 at 10:40 PM
The OnGUI system currently has no support for multi-touch, although it probably should work in combination with other elements. It's best to leave OnGUI out of gameplay anyway for performance reasons (can still be used with menus OK).
jesus that was fast, thanx for clearing that up, I will use a GUI texture to touch.
Answer by Murcho · Sep 23, 2010 at 10:39 PM
Sounds like you only have single touch enabled. Check the iPhoneInput.multiTouchEnabled variable, and if it's false, just set it to true.
Checking iPhoneInput.multiTouchEnabled won't help because OnGUI controls currently do not support mul$$anonymous$$ch at all.
Answer by Dreamora · Sep 23, 2010 at 10:46 PM
Check out the iphone example projects in the unity3d.com - support - resources section, they contain code for input sticks etc tailored for the iphone.
Answer by sunnykhan4u21 · Jan 20, 2011 at 03:38 AM
have you solved this issue? because i am having the same problem
Sorry, not on my main account. Yes I use GUITexture Game Objects now ins$$anonymous$$d of OnGUI functions.
Answer by Ouss · Jan 25, 2014 at 10:53 PM
Hi, In order to make the button clickable while moving with the joystick/or another button is active 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 create buttons using iphone look and feel?? 2 Answers
iPhone Touch Screen? 2 Answers
Touch GUI texture to toogle animation 0 Answers
Checking if a GUI Button was initiated? 0 Answers
DrawTexture GUI iPhone 1 Answer