Keep cursor in the middle of the screen?

I found this line of code that hides my cursor when the game starts, but I am wanting to change it so it keeps my cursor in the middle of the screen so it cant wander off. Can anyone help me out?

Screen.showCursor = false;

Check out this thread, it should help:

Basically, you can’t lock the cursor in place through Unity, but you can do it using a windows dll. Alternatively, you can lock the cursor in the center of the screen if you don’t mind it being hidden by using Screen.lockCursor = true. If you go this way, you can add a GUI texture of a cursor that appears when lockCursor is on, and turns off when it turns off.