# Hide Cursor Problems

**URL:** https://discussions.unity.com/t/hide-cursor-problems/93056
**Category:** Questions & Answers
**Created:** [January 17, 2014, 7:45pm UTC](https://discussions.unity.com/t/hide-cursor-problems/93056 "2014-01-17T19:45:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yojo890](https://avatars.discourse-cdn.com/v4/letter/y/45deac/32.png) [@yojo890](https://discussions.unity.com/u/yojo890)
#### Post date: [January 17, 2014, 7:45pm UTC](https://discussions.unity.com/t/hide-cursor-problems/93056/1 "2014-01-17T19:45:20Z")

</div>

Hello, so im a noob at this and im having problems, I have this script that I want to hide and lock the cursor on startup, and unlock and show the cursor when I press escape.  
But heres the problem, after I press escape to unlock and show, and I press escape to lock and hide the cursor again, it only hides the cursor and doesnt lock it in place, what am I doing wrong?

var showingMouse : boolean;

```
function Start () {
	showingMouse = false;
	Screen.showCursor = false;
	Screen.lockCursor = true;
}
	

function Update () {
	//if escape is pressed, unlock cursor and show cursor
		if (Input.GetButtonDown("Esc") && showingMouse == false){
			showingMouse = true;
			Screen.showCursor = true;
			Screen.lockCursor = false;
	}	
	
		else if (Input.GetButtonDown("Esc") && showingMouse == true){
			showingMouse = false;
			Screen.showCursor = false;
			Screen.lockCursor = true;
	}
	
}

```

---

<div class="post-metadata">

### Author: ![TimBorquez](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@TimBorquez](https://discussions.unity.com/u/TimBorquez)
#### Post date: [January 20, 2014, 8:01pm UTC](https://discussions.unity.com/t/hide-cursor-problems/93056/2 "2014-01-20T20:01:00Z")

</div>

lock cursor should hide and center the cursor

remember that lock cursor wont work exactly right in the editor, only in the build

try this code to just toggle it

```
 if (Input.GetButtonDown("Esc"))
{
Screen.lockCursor = !Screen.lockCursor;
}

```
