简体   繁体   中英

How can I convert a tap gesture for my HoloLens App to a mouse click for my Desktop App?

I have developed a HoloLens Application and it involves the usage of gestures such as tap, pinch, and drag, etc. I now want to use the same Application on my desktop as a Windows Desktop Application. How do I ensure that tapping on the HoloLens app is the same as a mouse click on the Windows Desktop app and pinch and drag is the same as click, hold and drag?

At first, I used the UWP Platform to build the app and then built and deployed it on Visual Studio. On doing so, a .exe file is getting generated and I'm being asked to set up Mixed Reality Portal and use a headset in order to use the app. However, using a headset defeats the purpose of my Windows Desktop App. I then used the PC, Mac and Linux Standalone Platform to build and create the app. However, in order to build the app, I had to comment out all my scripts as the gestureRecognizer and PhotoCapture were causing issues. I have then added two scripts in order to use the mouse as a camera. That is working fine. Is there any way to use the mouse for clicking purposes as well? For example, click should be the same as tap and click, hold, the drag should be the same as pinch and drag?

using UnityEngine.XR.WSA.Input;
using UnityEngine.XR.WSA.Webcam;

Assets\\Sphere.cs(7,26): error CS0234: The type or namespace name 'WebCam' does not exist in the namespace 'UnityEngine.XR.WSA' (are you missing an assembly reference?)

Assets\\Sphere.cs(4,26): error CS0234: The type or namespace name 'Input' does not exist in the namespace 'UnityEngine.XR.WSA' (are you missing an assembly reference?)

I am receiving these errors on trying to build it on UWP Platform. I am only receiving these errors on choosing to build it for PC. It is working just fine for the HoloLens.

At first, I used the UWP Platform to build the app and then built and deployed it on Visual Studio. On doing so, a .exe file is getting generated and I'm being asked to set up Mixed Reality Portal and use a headset in order to use the app. However, using a headset defeats the purpose of my Windows Desktop App.

To create a standard non-XR app, you need to go into Project Settings > Player Settings > UWP Tab (blue Windows logo) > XR Settings and uncheck the "Virtual Reality Supported" option.

As for receiving mouse input, you can look into using the IPointerClickHandler here: https://docs.unity3d.com/ScriptReference/EventSystems.IPointerClickHandler.html

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