- Home /
GUI button is being triggered by 2 fingers on screen.
I have a very strange thing happening here. I have three gui buttons.On in the lower left corner, one in the lower right corner and now in the lower middle. Strangely I have noticed that if ( on IOS) i hold my finger on one of the corner buttons and then touch the other corner button( so that both buttons are being pressed,what actually happens is that the MIDDLE button is the one that actuates! How the heck is this happening?
Actually, I have also found that if I touch the screen( and hold) with one finger and then touch the screen with a second finger, then whichever GUI button happens to be directly in the middle will be triggered. This does'nt seem right.
Have you solved this problem? I am facing the exact problem. I have three buttons. If i have two fingers over and under the button it triggers the button in between the fingers. This happens for every GUI.Button.
Answer by Owen-Reynolds · Jun 07, 2013 at 02:59 PM
You're probably using Input.MousePosition
. It's really for a single mouse, but for touch screens it supposedly averages the position of all touches (I haven't tested it.) So upper-left+lower-right = middle.
Use the official way instead. To assume 1 touch at a time: if(Input.touchCount==1) pos = Input.touches[0];
. A number of mobile games work that way -- just resting one finger on empty screen space makes tapping a button impossible.
If you want to handle multiple touches and things like "started and ended over the same button" you have to do more work, or look for a UnityStore package.
Your answer
Follow this Question
Related Questions
GUISkin breakages 2 Answers
GUIStyle not working on GUI.Button 4 Answers
button drawn last not triggered 0 Answers
Why is Unity registering my false boolean as true? 1 Answer
OnGUI button created by a foreach loop 4 Answers