简体   繁体   中英

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. 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. I am using Unity 2018.2. I want to make UI that changes color when I touch inside of a certain region on the touchpad. 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. 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. 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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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