Locking the mouse cursor in game window

So I’m trying to get the mouse to be locked inside the game window so I don’t click anything outside the game when I have to click a mouse button for an in-game feature.

I’ve tried Screen.lockCursor = true but that’s not what I want, that makes the mouse not visible locks it in one place but what I want is to keep the mouse just inside the game window.

Any ideas on how to do this?

Thanks in advance.

I don’t think you can do this. my best advice would be to turn on maximize on play.

Well that’s not going to work on a webplayer right lol, so I need to figure this out :frowning:

Ah didnt realize you were talking about the webplayer. In that case i highly doubt there is a way to do this and keep the Event system in tact for GUI. For good reason too, like you wouldn’t want someone to be locked in to your game and not be able to move outside of it ( or maybe you would :slight_smile: ) but i think putting that much reliability on the user code is bad. I know in flash you cannot even lock the cursor to begin with.

You can enable full screen in the webplayer. maybe a suggestion to have the person do that would work?

Lol, yeah all that is true, thanks anyaways mate :slight_smile: