1//to lock in the centre of window
2Cursor.lockState = CursorLockMode.Locked;
3//to hide the curser
4Cursor.visible = false;
5
6
7Cursor.lockState = CursorLockMode.None;
8Cursor.visible = true;
1Cursor.lockState = CursorLockMode.None; // to unlock cursor
2Cursor.visible = true; // to make cursor visible
1Well im pretty new in Unity so,, this thing: http://docs.unity3d.com/ScriptReference/Cursor-visible.html
2and http://docs.unity3d.com/ScriptReference/Screen-lockCursor.html somehow does not work for me. What i want? Simply to hide cursor (so it wont be visible but will still be in the middle of the screen) so i can put some mine cursor on ,,, let me say, UI ,,,, , In Unity 4.something i was use:
3
4Code (JavaScript):
5function Update()
6{
7Cursor.visible = false;
8Screen.lockCursor = true;
9Screen.lockCursor = false;
10}
11And everything worked fine till Unity 5 where i get warning (and also this old script does not work anymore)
12Assets/SCRIPTS/CenteredShowCursor.js(5,8): BCW0012: WARNING: 'UnityEngine.Screen.lockCursor' is obsolete. Property lockCursor has been deprecated. Use Cursor.lockState and Cursor.visible instead..
13Is it any simply code to HIDE and Lock game cursor but still be able to use it in game ("to click on some objects inside the game")