如何在Unity中找到鼠标位置?我正在使用新的输入系统并且我已经尝试过
InputDevice mouse = Mouse.current;
Ray ray = camera.ScreenPointToRay(mouse.position);
,但没有用。有人吗?
使用这个:
Ray ray = camera.ScreenPointToRay(Mouse.current.position.ReadValue());
using UnityEngine.InputSystem;
float mouseX = Mouse.current.position.x.ReadValue();
float mouseY = Mouse.current.position.y.ReadValue();
Ray ray = camera.ScreenPointToRay(new Vector3(mouseX, mouseY, 0));