- Home /
Question by
ewanvanvan · Jul 13, 2018 at 08:37 AM ·
c#mousegetgetmousebuttondown
How do I make mouse clicks to be processed only where I need it?
There is an object on the stage (let's call it the button). So I need that when I poke it with a mouse in the console wrote a message (for example: it works). For this, I wrote the script using GetMouseButtonDown. And added this script to the button. But for some reason when I start the game and I do not click on the button, the console still writes: it works. How do I make mouse clicks to be processed only where I need it?
Comment
Best Answer
Answer by Bartson · Jul 13, 2018 at 09:10 AM
Just create simple public void and attach it to OnClick in inspector. GetMouseButtonDown check if you clicked anywhere.
Your answer
![](https://koobas.hobune.stream/wayback/20220612170626im_/https://answers.unity.com/themes/thub/images/avi.jpg)