Ethranes
Ethranes

Reputation: 359

Cursor can't move on scene switch Unity 5

I have an issue in my project at the moment, after a player finishes a level a new scene is loaded but I'm not able to move the mouse cursor. To begin with it wouldn't show either so I added the code;

Cursor.visible = true;

Now the mouse cursor is visible but I still can't move it from the center of the scene. Any help or advice would be appreciated.

Upvotes: 3

Views: 3119

Answers (2)

William Pagan
William Pagan

Reputation: 1

You can also do a script that will call it once on the void Start() an example that will work.

Place the script anywhere or on the canvas or create an empty Object and place this script on it.

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

That will work once you leave the scene and go back to it using the script above it will kick in, and Cursor will work and begin to interact with the loaded scene.

It shouldn't be that way, but it works. Cheers!

WP

Upvotes: 0

TerraPass
TerraPass

Reputation: 1602

You may need to reset lockState to None as well:

Cursor.lockState = CursorLockMode.None;

See Cursor.lockState documentation.

Upvotes: 3

Related Questions