Constrain the cursor to the window

I have found:

Cursor.lockState = CursorLockMode.Confined;

But they only work in a fully build game not in the editor. Do I have to do something special for it to work in the editor window?

Am I the only one with this problem? Does Cursor.lockState = CursorLockMode.Confined; work for you in the editor?

It also doesn’t fully work in a standalone build. The cursor is still able to move over the title bar.

Am I the only one with this problem? For me this is pretty much a deal breaker. The only workaround that I can think of would be to use the win32api.

Hide & lock windows cursor and make your own in the game