screen.lockcursor locks the cursor in wrong place

void Start () {
Screen.lockCursor = false;
Screen.lockCursor = true;
}

// Update is called once per frame
void Update () {
if(Input.GetKeyUp(KeyCode.Tab))
	{
		Screen.lockCursor = !Screen.lockCursor;
	}
}

Such a simple code and it doesn’t work. I attached it to an empty GO inside the scene. The problem seems to be that the cursor locks in wrong place (an afaik it should lock in the middle of the screen) - when I hit tab for the first time I can see it’s location and it’s usually somewhere far right - after that when I hit tab, everything is back to normal, so the problem seems to appear only on level startup. Any thoughts?

That’s just an issue in the editor. It have been discovered long time ago :wink:

Any build version should be ok.

In the editor a lot things happens additionally. When switching from edit to run mode the whole scene gets serialized and recreated. Also the behaviour is different when you have both view visible (scene view and game view) instead having them in the same dock window as tabs.

Personally i always have both visible (game view at the top scene view below)