My issue is this one I try to acces my inventory to equip diferent items and I ususaly hit the “esc” key to show the mouse coursor and to unlock it, either way when I select the item I need the cursor locks again.
Here is the code I’m using, my unity version is Unity 5.6.1f1 64 bit
I’m using C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CursorUnlock : MonoBehaviour
{
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.T))
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
}