how do i amke a mouse lock script that when i press escape the mouse will apear but the rest of the time its locked and hidden
I’m not looking at the docs right now, but check the scripting reference for the Screen class; there’s a couple of properties there for showing/hiding and locking/unlocking the cursor.
The bool Screen.lockCursor should do you want, be aware that in, for example, the web player the end user has to click on your Unity embed before this can be done. As I recall, the lock also gets reset at some point when entering/exiting fullscreen but it’s been a while since I did that.
For web apps it’ll automatically unlock on hitting escape; you’ll have to use the Input class to check when escape is pressed for a standalone app.
Edit: Just found a good reference script in the docs: Unity - Scripting API: Screen.lockCursor