正题,既然是InputSystem,那就有可以用API供调用:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//声明 static public Vector3 mousePosition { get => Mouse.current.position.ReadValue(); set { Mouse.current.WarpCursorPosition(value); InputState.Change(Mouse.current.position, value); } } //运用 vector3 pos = Vector3.zero; mousePosition = pos; |
完~ 顺滑!!
盗个市面上的方法,如果想多平台,就别使用它:
1 2 |
[System.Runtime.InteropServices.DllImport("user32.dll")] //引入dll public static extern int SetCursorPos(int x , int y); |