How to hide the cursor

Hello,

I want to hide the cursor as I am using a gamepad instead of mouse and keyboard.

Would this code work for that:

Screen.showCursor = false;

and if so where show it go?

I am really new, and have no experience coding (dont really know how i made it this far)

Cheers,

Sabrina

@Spy4812 please don't post a new question as a comment or answer.

8 Answers

8

If you want to hide the cursor through the entire game you should add the "Screen.showCursor = false"-code inside the Start function ;)

like so:

void Start ()
{
    Screen.showCursor = false;
}

(in C#)

or:

function Start ()
    {
        Screen.showCursor = false;
    }

(in JavaScript)

Cool and super simple, wish I had the rep to upvote this!

this does not work it says the this is obsolete

this is not working in unity 2017

If you also want to hide the cursor AND lock it in the center of the screen, you should use

Screen.lockCursor = true;

but this is not working in Unity 2017.1.0f3

For those using unity 5 or above, Its “Cursor.visble = false;” (C#) to hide the cursor.

//for Unity3d 5
using UnityEngine;
using System.Collections;

public class CurserRemove : MonoBehaviour {

// Use this for initialization
void Start () {
	Cursor.visible = false;

}

// Update is called once per frame
void Update () {

}

}

It does not work for me the cursor is still there

ive never coded can some one tell me where to add this script or how to please

If you are new watch and read a few guides, like http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-(long)

thanks thats exactly what i wanted to do, to show and hide the mouse by one button

To remove your mouse from the screen, create a neew c# script and then clear everything out of it
the copy and paste the following into the script:

using UnityEngine;
using System.Collections;

public class CursorDelete : MonoBehaviour {
void Start ()
    {
    Screen.showCursor = false;
    Screen.lockCursor = true;
	}
}

‘Cursor.visible = false;’ with the correct spelling

Not sure who asked but yeah, to lock cursor in the middle of the screen using UNITY:
Cursor.lockState = CursorLockMode.Locked;