First person template unity issue with ui

The title gives it away already, probably, but I will explain in more detail. I just wanted to make a new game that will be happening in first person. I saw that Unity had a template, so I thought I would use that. Everything works fine unless I started adding UI. So the template already offers the option to click ESC to freely move the mouse. But as soon as you click on a UI button, the mouse gets locked again. I tried to fix it, but I am pretty new at scripting, which is also why I use this template, and at some point, after spending a whole day going through so many scripts, I gave up.

Do a search in all code for Cursor.lockState and Cursor.visible to see where it's being set to true/false. You should then be able to debug the issue.

–