- Home /
Isolate screen taps from button clicks
I'm counting screen taps in my app using (Input.touchCount == 1 && Input.GetTouch (0).phase == TouchPhase.Ended))
I also have some buttons in my interface, I used both OnGUI buttons, as well as NGUI buttons with box colliders.
Is there any way to exclude tap counts when pressing on the buttons?
If i remember correctly NGUI has its own Events for inputs, it would be better to use them for checking inputs if you want to stick to NGUI. search for it in NGUI forums, you would get something for sure!.
I wouldn't want to change too much of my code at this point, I'm going to check NGUI in more detail in later projects, could I use different layers to use in my conditions?
//the below lets you check for the back button on android and IOS as I understand it. //so making some of the se up and finding their common/standard references like...
if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.Escape))
{
//then something along the lines of...
Input.touchCount = 0; //make touches not equal to 1 ensuring your tap count is not incremented
}
Just in case, here is there $$anonymous$$eyCode list for Unity and you will most likely find that like "$$anonymous$$eyCode.Escape" you can access your other buttons similarly.
If this question is referring to GUI buttons, then the same principle would apply, making Input.touchCount equal to 0 when you press a gui button etc. Take care hope that helps some. Gruffy
yes, different layers are possible using GUI.Layer. Cheers bud Gruffy
Hmmm.. How exactly is checking for the escape button going to help me with my issue?
Answer by Kamuiyshirou · Apr 03, 2014 at 09:27 PM
It's not hard. You only need to worry about leaving DISABLED conditions that enable the specific location you want to isolate. Do not think in general, consider each one individually.
Your answer
![](https://koobas.hobune.stream/wayback/20220613141748im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Selecting an object on click, then clicking a UI button to change its color. 1 Answer
When pressing a button, it counts as pressing the screen and the button [New Input System] 0 Answers
multi toch GUI buttons 1 Answer
How to add touchscreen controls to this script? 0 Answers
Button key assignment? 1 Answer