How do I lock cursor to the center of the screen?

All I see is people saying stuff like:

    void Start()
    {
        Screen.lockCursor = true;
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = true;

    }

but none of these do squat, so I’m wondering: How do I really lock the cursor to the center of the screen?

public class CursorLock : MonoBehaviour
{
public static void CursorOn()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}

    public static void CursorOff()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }
}

I cannot believe there is not a solution for this. i’ve spent 4 days searching and trying everything i can find.
is there a unity employee talking about this somewhere ???

if so please link me!!!