Unity 5.0 Cursor lock issue

I think everyone is having this issue because so far there aren’t any answers to the problem.

i changed my lock code script to work with the new Cursor.lockState code. BUT currently it’s got the problem of not re grabbing the cursor to the center of the screen and it just goes where it wants.

Here’s my code.

using UnityEngine;
using System.Collections;

public class PauseG : MonoBehaviour {

	public bool PauseGame = false;

	void Start(){
	}

	void Update(){
		// Pauseing Variables
		if(PauseGame == false){
			Time.timeScale = 1;
			Cursor.lockState = CursorLockMode.Locked;
		}else{
			Time.timeScale = 0;
			Cursor.lockState = CursorLockMode.Confined;
		}
		//Key check
		if(Input.GetKeyDown(KeyCode.Escape)){
			if(PauseGame == false){
				PauseGame = true;
			}else{
				PauseGame = false;
			}
		}
	}
}

It has problems capturing the mouse unless I click in the window.

Please help, this has been stressing me out for the past week.

From what I have read/experienced, it doesn’t seem to work unless the user clicks in the window. Then it locks fine (not very brilliant/useful in my opinion though). Apparently it has been an issue for a while now.