简体   繁体   English

如何将HoloLens应用程序的轻击手势转换为桌面应用程序的鼠标单击?

[英]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. 我已经开发了HoloLens应用程序,它涉及手势的使用,例如轻击,捏和拖动等。我现在想在桌面上使用与Windows桌面应用程序相同的应用程序。 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? 如何确保在HoloLens应用程序上点击与在Windows Desktop应用程序上单击鼠标相同,并且捏和拖动与单击,按住并拖动相同?

At first, I used the UWP Platform to build the app and then built and deployed it on Visual Studio. 最初,我使用UWP平台构建应用程序,然后在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. 这样做会生成一个.exe文件,并要求我设置Mixed Reality Portal并使用耳机才能使用该应用程序。 However, using a headset defeats the purpose of my Windows Desktop App. 但是,使用耳机无法达到Windows桌面应用程序的目的。 I then used the PC, Mac and Linux Standalone Platform to build and create the app. 然后,我使用PC,Mac和Linux独立平台来构建和创建应用程序。 However, in order to build the app, I had to comment out all my scripts as the gestureRecognizer and PhotoCapture were causing issues. 但是,为了构建该应用程序,我不得不注释掉所有脚本,因为gestureRecognizer和PhotoCapture引起了问题。 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(7,26):错误CS0234:类型或名称空间名称'WebCam'在名称空间'UnityEngine.XR.WSA'中不存在(您是否缺少程序集引用?)

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?) Assets \\ Sphere.cs(4,26):错误CS0234:类型或名称空间名称“输入”在名称空间“ UnityEngine.XR.WSA”中不存在(您是否缺少程序集引用?)

I am receiving these errors on trying to build it on UWP Platform. 我在尝试在UWP Platform上构建它们时收到这些错误。 I am only receiving these errors on choosing to build it for PC. 在选择为PC构建它时,我仅收到这些错误。 It is working just fine for the HoloLens. 对于HoloLens来说效果很好。

At first, I used the UWP Platform to build the app and then built and deployed it on Visual Studio. 最初,我使用UWP平台构建应用程序,然后在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. 这样做会生成一个.exe文件,并要求我设置Mixed Reality Portal并使用耳机才能使用该应用程序。 However, using a headset defeats the purpose of my Windows Desktop App. 但是,使用耳机无法达到Windows桌面应用程序的目的。

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. 要创建标准的非XR应用,您需要进入项目设置>播放器设置> UWP选项卡(蓝色Windows徽标)> XR设置,然后取消选中“支持虚拟现实”选项。

As for receiving mouse input, you can look into using the IPointerClickHandler here: https://docs.unity3d.com/ScriptReference/EventSystems.IPointerClickHandler.html 至于接收鼠标输入,您可以在这里使用IPointerClickHandler进行调查: https ://docs.unity3d.com/ScriptReference/EventSystems.IPointerClickHandler.html

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

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