using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CursorLock: MonoBehaviour
{
bool HideCursor = true
void Update()
{
KeepCursorCenter();
}
private void KeepCursorCenter()
{
if(input.GetKeyDown(KeyCode.Escape))
{
HideCursor =!HideCursor;
}
if(HideCursor=ture)
{
//锁定时,光标位于视图的中心且无法移动。
Cursor.lockState = CursorLockMode.Locked;
}
else
{
Cursor.lockState = CursorLockMode.None;
}
}
}


