Execute code when clicked anywhere except on UI buttons
In my mobile game I have a menu. You can tap everywhere to start playing. In the same screen I have UI button, but when i click it unity thinks I tapped to start playing , while in reality I wanted to click UI button! Is there a clean solution , how I could block tap everywhere functionality when I click on UI buttons ?
Green : for tap everywhere I use just a simple Input.PressKeyDown()
Red : UI buttons I want "tap everywhere to play" functionality to not work
Have you made research before asking ? http://answers.unity3d.com/questions/784617/how-do-i-block-touch-events-from-propagating-throu.html
Yes I did, but probably because of my limited English and imagination I searched using bad keywords, I am sorry.
Answer by SmomoGame · Dec 28, 2016 at 02:13 PM
You can put a full transparent image(or button) under all UI elements, and make it fill up canvas.
This image can be clicked but won't be triggered if you click other ui elements, then just add some events to this "dummy image".
Notice: this image must be first child(first layer when render), or it would block others