Unity 考虑的很周全, 所以代码量很少 (才10行), 不多说直接看代码
public static Vector2 mousePos{get => GetMousePos();set => SetMousePos(value);}public static Vector2 GetMousePos(){return (Mouse.current == null) ? Vector2.zero : Mouse.current.position.ReadValue();}public static void SetMousePos(Vector2 pos){Mouse.current.WarpCursorPosition(pos); //切换光标位置InputState.Change(Mouse.current.position, pos); //应用}