- Home /
Detect mouse click anywhere on the screen using New Input System
Hi, I am currently trying to implement a context menu that pops up next to the user's cursor when the user clicks an item, similar to when you right click in most other applications. It doesn't seem like Unity has a built-in component for this. This context menu should then disappear if the user clicks anywhere, whether on the menu or not.
There is a way to do it in the old input system https://answers.unity.com/questions/34249/basic-mouse-click-anywhere-for-something-to-happen.html but it doesn't work for the new input system.
If there's no easy way to do this, I will use a hacky idea inspired by another post I read: A giant invisible button that appears right behind the context menu, which can detect the click. But that would be a weird way to do this especially for something that seems like a trivial and common use case.
Another downside is, if I do the hacky way, then other UI elements can't get their on-click event while the menu is active.
Your answer

Follow this Question
Related Questions
Trigger animation OnMouseDown 0 Answers
Unity Lock Up and Mouse Clicking Issue 1 Answer
how to make wind 3 Answers
Prevents a mouse click on interface to trigger a click to move script 1 Answer
Detect a click outside a GUI/object 4 Answers