问题
I wrote the following update:
void Update () {
if( Input.GetMouseButton(0) )
{
if( !dragging )
{
dragging = true;
xDragStart = Input.GetAxis("Mouse X");
yDragStart = Input.GetAxis("Mouse Y");
}
xDrag = Input.GetAxis("Mouse X");
yDrag = Input.GetAxis("Mouse Y");
DragValuesText.text = "x = " + xDrag + ", y = " + yDrag;
}
else
{
if( dragging )
{
dragging = false;
}
}
}
and made a Text
UI to display DragValuesText
. After this I found, that returned values are small while I am dragging and turn to zero if I stop the mouse. Looks like they return delta. But how can I be sure?
In documentation I don't see it is definitely delta. It says it CAN be delta, but how to know or change this fact -- it is not said.
回答1:
Go into Edit -> Project Settings -> Input and check the settings for the Mouse X / Mouse Y axes.
The Type
should be "Mouse movement" by default, which means its "mouse delta"
Use Key / Mouse Button for any kind of buttons, Mouse Movement for mouse delta and scrollwheels, Joystick Axis for analog joystick axes and Window Movement for when the user shakes the window.
https://docs.unity3d.com/Manual/class-InputManager.html
来源:https://stackoverflow.com/questions/50889727/what-does-mouse-x-and-mouse-y-return-in-unity