- Home /
Unity Cursor changing back
I've problem using
Cursor.Lockstateand
Cursor.visiblehere is the full code:
if (Input.GetKeyDown("e"))
{
InventoryStat = !InventoryStat;
if (!InventoryStat)
{
Cursor.lockState = CursorLockMode.None;
Cursor.lockState = CursorLockMode.Confined;
Cursor.visible = true;
INV.gameObject.SetActive(true);
}
else
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
INV.gameObject.SetActive(false);
}
}
When i press "e", the gui appears. but the mouse appears for one second and then instantly disappears. but when unlock the mouse with escape, it now wont disappear when pressing "e". I have searched the entire internet for this problem but i cant find anything.
any help appreciated!
Answer by FortisVenaliter · Jan 26, 2017 at 06:06 PM
Unlocking the mouse with escape is editor only. So, if you're manually changing the lock state, that will override it. You can't expect the escape unlock to work in the built game, so test around it, not with it.
It should, but build it and test to be sure.
Your answer
Follow this Question
Related Questions
Turning curser on and off 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Cursor changed on button hover, but how to change it back if object is destroyed? 1 Answer
How can I do this with gizmos? 0 Answers