简体   繁体   English

如何在Unity3D中获得触摸板的绝对位置/触摸板上的位置

[英]How to get absolute position of touchpad/position touched on touchpad in Unity3D

How can I get the absolute position touched on the touchpad? 如何获得触摸板上的绝对位置? My laptop has a Synaptics touchpad and its fine if it only works on this touchpad. 我的笔记本电脑配有Synaptics触摸板,如果只能在此触摸板上使用,则可以使用。 I'm trying to create an interaction with UI that will show as focused based on the section of the touchpad touched but I'm not sure where to begin getting the position touched. 我正在尝试创建与UI的交互,该交互将基于触摸板的触摸区域显示为焦点,但我不确定从何处开始触摸位置。 I am using Unity 2018.2. 我正在使用Unity 2018.2。 I want to make UI that changes color when I touch inside of a certain region on the touchpad. 我想让UI在触摸板上的某个区域内时会改变颜色。 How can I get the coordinates touched in the touchpad? 如何获得触摸板中触摸的坐标?

This functionality is not something that can be achieved without highly specific SDK integration based on the touchpad being used, which will limit what hardware can use the app. 如果不使用基于触摸板的高度特定的SDK集成,则无法实现此功能,这将限制哪些硬件可以使用该应用程序。 Think about the trackpad as just a mousepad and your fingers as the mouse. 将触控板想像成只是一个鼠标垫,而手指想像成鼠标。 There's no way for Unity or the system in general to know where your finger is on the trackpad, just like it can't know where your mouse is on the mousepad. 一般来说,Unity或系统无法知道手指在触控板上的位置,就像无法知道鼠标在触控板上的位置一样。 That information is managed at a level that is specific to the hardware and just translates the cursor position to the OS to pass on to software in a generic way (aka position deltas). 该信息在特定于硬件的级别上进行管理,仅将光标位置转换为OS,然后以通用方式(即位置增量)传递给软件。 This is why touchpads don't use the touch input library, but rather the mouse input library. 这就是为什么触摸板不使用触摸输入库,而是使用鼠标输入库的原因。 All you can do is track where your cursor started, and the drag delta of fingers in screen space. 您所能做的就是跟踪光标的开始位置以及屏幕空间中手指的拖动增量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM