user3583094
user3583094

Reputation: 105

How to lock and hide the cursor in Unity3D?

It's a simple question, but how do I lock the cursor and hide the cursor in my Unity games?

Upvotes: 1

Views: 4078

Answers (3)

Random Person
Random Person

Reputation: 11

It is better to use this:

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

Because Screen.ShowCursor is deprecated.

Upvotes: 0

Droppy
Droppy

Reputation: 9731

As of Unity 5.2, you should use the Cursor class.

Static Variables

lockState How should the cursor be handled?

visible Should the cursor be visible?

Upvotes: 6

Rahul Tripathi
Rahul Tripathi

Reputation: 172578

You can try like this:

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

ie, try to add Screen.showCursor = false inside the Start function. This will hide the cursor from the entire game.

Also refer: Screen.lockCursor

Upvotes: 1

Related Questions