本文介绍了如何检测您的Mixed Reality应用程序是在HoloLens 1,HoloLens 2还是沉浸式耳机上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

混合现实应用程序可以很快在三种设备上运行:HoloLens 1,Hololens 2和沉浸式(VR)耳机.某些行为可能会有所不同,具体取决于您运行该应用程序的设备的类型.如何询问SDK我的应用当前正在运行哪种设备?

Mixed Reality apps can soon run on three kinds of devices: HoloLens 1, Hololens 2 and Immersive (VR) headsets. Some behavior will likely be different depending on the type of device you run the app on. How can I ask the SDK what kind of device my app is running currently on?

推荐答案

如果您使用的是MRTK(我注意到您可能基于您的标签),那么最好的方法是使用平台功能实用程序,因为它将随着新设备的出现和跨平台的出现而起作用.例如,您可以选择我的设备是否支持铰接的手?",而不是选中在HoloLens 2上开机".然后,它将在支持关节手的其他平台上工作.例如,在MRTK示例中检查MixedRealityToolkit.Examples/Demos/Utilities/Scenes/MixedRealityCapabilityDemo.unity.

If you are using MRTK (I noticed you might based on your tag), then the best way to do this is by using platform capabilities utility, since that will work as new devices come out, and across platforms. For example, instead of checking "am on on HoloLens 2" you can check "does my device support articulated hands?". That will then work on other platforms that support articulated hands. For an example, chekc out MixedRealityToolkit.Examples/Demos/Utilities/Scenes/MixedRealityCapabilityDemo.unity in MRTK examples.

如果现在需要临时解决方案以区分WMR与HL1与HL2,则可以使用以下代码.请注意,它仅适用于Windows:

If you need a temporary solution for now to differentiate WMR from HL1 from HL2, you can use the following code. Note it's windows-only:

using Windows.Security.ExchangeActiveSyncProvisioning;

EasClientDeviceInformation CurrentInfo = new EasClientDeviceInformation();
string sku = CurrentInfo.SystemSku;

HoloLens 1,HoloLens 2和沉浸式耳机应全部返回不同的字符串.

HoloLens 1, HoloLens 2, and Immersive headsets should all return different strings.

编辑6/5/2020:

Edit 6/5/2020:

还可以如下检查运行时平台:

It's also possible to check the runtime platform as follows:

if (Application.platform == RuntimePlatform.WSAPlayerARM)
{
     // Running HoloLens 2, most likely.
}

这篇关于如何检测您的Mixed Reality应用程序是在HoloLens 1,HoloLens 2还是沉浸式耳机上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 20:05