- Home /
Preventing mouseclicks outside the game window
Hi,
I am making a 2D sprite-based brawler type of game that (unlike most others) utilize mouseclicks quite extensively.
Because of the frantic nature of the gameplay, testers are finding that they accidentally click outside the window (in windowed mode) much more often than we'd like. I was wondering if Unity has an option to disable all interactions outside of the window while the game is running.
I have read this topic: http://answers.unity3d.com/questions/273902/disabling-view-of-mouse-outside-of-unity-window.html
This seems like a good solution except that it hides the mouse cursor and restricts its movement inside the window. Is there anything like this but allowing regular mouse movement within the game window?
Edit: The ideal solution would allow full movement and clicking inside the game window but would not allow the cursor to exit the window while the game is running.
Answer by sfc.itzhak · Oct 25, 2012 at 10:43 PM
is the issue that you loose focus?
or you just dont want them to accidently click outside?
for the first one you can click on reun in background and it wont effect gameplay.
Hi,
Thanks for your input. However, I have tried this approach and since it loses focus on the game window, it was deemed to be too disruptive to gameplay.
Also, If you have a full screen browser or something in the background it will cover the game. As it remains running in the background, when you return, you will probably be dead.
It would be best if the mouse could not exit the game window while the game is running.
Your answer
![](https://koobas.hobune.stream/wayback/20220613082902im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Top-Down 2D game:How to make the camera move on hitting the sides of the screen? 2 Answers
Making a ball follow my mouse only on the y axis, and let it automatically move on x axis 2D 2 Answers
window mode and full screen mode 1 Answer
How to make a 2D character points his gun to the mouse position? 2 Answers
How to always have the mouse curser in the center of your game ? 3 Answers