“鼠标X"是什么?和“鼠标Y"在 Unity 中返回? [英] What does "Mouse X" and "Mouse Y" return in Unity?

查看:311
本文介绍了“鼠标X"是什么?和“鼠标Y"在 Unity 中返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了以下更新:

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;
            }
        }


    }

并制作了一个 Text UI 来显示 DragValuesText.在此之后,我发现,当我拖动时返回的值很小,如果我停止鼠标,则返回值为零.看起来他们返回了delta.但我怎么能确定呢?

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.

推荐答案

进入编辑 -> 项目设置 -> 输入并检查鼠标 X/鼠标 Y 轴的设置.

Go into Edit -> Project Settings -> Input and check the settings for the Mouse X / Mouse Y axes.

Type默认应该是鼠标移动",即它的鼠标增量"

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

这篇关于“鼠标X"是什么?和“鼠标Y"在 Unity 中返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆