Cursor.visible not working?

Hello, I am curious as to why I can’t figure this one out. I have one scene acting as a main menu. I need the cursor to show on start, this here says it would work…

void Start()
{
    Cursor.visible = true;
}

That doesn’t work, so I tried something like this instead.

public bool cursorOn;

void Start()
{
   cursorOn = true;
}

void Update()
{
   if(cursorOn == true)
   {
       ShowCursor();
   }
   else if(cursorOn == false)
   {
       HideCursor();
   }
}

void ShowCursor
{
    Cursor.visible = true;
    Cursor.lockState = CursorLockMode.None;
}

void HideCursor()
{
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
}

Nothing I have tried after that has worked, so I am coming here to hopefully find it out. The only stuff I could find online was exactly what I tried, but it didn’t work. It used to be so much easier Unity, why did you need to change this…?

had same issue, just restarting unity worked for me (remember to safe),had same problem
at me it was just restarting unity, no scripting issues

in my case an external script on Camera executing every frame hid the cursor

Here is the solution. Just apply this script to an active gameobject in your scene.

Note that in the Editor, the game frame needs to have focus straight after you press Play for this to work correctly (ie click on it straight after clicking the Play button)

public class LockCursor : MonoBehaviour
{

    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    void OnApplicationFocus(bool hasFocus)
    {
        if (hasFocus)
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;
        }
    }

}