unity中锁定鼠标移动&&隐藏鼠标&&强制是鼠标移动到某一位置
[System.Runtime.InteropServices.DllImport("user32.dll")] //引入dll
public static extern int SetCursorPos ( int x , int y );
void Update()
{
SetMouseToAnyOfScreenPosition();
}
void SetMouseToAnyOfScreenPosition()
{
SetCursorPos ( 20 , 20 );//放在update中,每帧调用,强制设置坐标
Cursor . visible = false;//隐藏鼠标
}