Isolating Screen Taps from UI Button Clicks

Hello,

I started to use Unity one week ago and I have many questions, and this is one of them.

I am doing a game for Android. In the game, when user taps to the screen “something” happens. Game also has UI buttons and their click events work with Event Triggers. But when I click on them, that “something” happens again. In other words, I tap to the screen when I click on buttons. How can I prevent from that situation?

Thanks in advance, sorry If I did mistakes about English.

2 Answers

2

But this into your script where you handle the “normal tap” to test whether you actually clicking an UI:

        if (EventSystem.current.IsPointerOverGameObject())
            return;

If you are using Input.GetMouseButtonDown(0) , it will work regardless of where are you taping on screen.

Below UI buttons add the UI panel with button component attach to it which will simulate your “Something” function. :slight_smile: