Cursor keeps being moved back to the center of the screen?

I have been trying to solve this for 3 days now and I have been unable to solve it myself. What is happening is when I open my inventory, my mouse is in theory supposed to be shown and unlocked. Now this almost works, except when I try to actually move my mouse around, it almost instantly gets moved straight to the center. I am using Unity version 5.4.0f3.

My code that does this (in the inventory script) is:

if (isShown) { // If the inventory is opened

			Cursor.visible = true;
			Cursor.lockState = CursorLockMode.None;
}

I have no other code that affects the cursor except for this in a separate script:

if (inventory.isShown || pauseManager.isPaused) { // If inventory is opened or game is paused
		Cursor.visible = true;
		Cursor.lockState = CursorLockMode.None;
		} else {
			Cursor.lockState = CursorLockMode.None;
		}

Any help would be greatly appreciated ~

Well it soley depend on how you actually lock the cursor. Also what platform do you build for? WebGL for example has some restrictions how the cursor locking works.

Usually when you use CursorLockMode.Locked, just as the documentation says, it will “lock the cursor to the center of the screen”.

Maybe you want to use CursorLockMode.Confined? However i’m not sure why it’s a problem when the cursor is in the screen center after locking. That’s how 90% of all FPS games work (HL, Quake and even Minecraft).

It’s not quite clear from your question if you see the cursor elsewhere after unlocking. If that’s the case it might be a bug either in the OS or Unity. Again, what platform are you build for? Do you actually test in the editor or in the actual build?