如何检测您的Mixed Reality应用程序是在HoloLens 1,HoloLens 2还是沉浸式耳机上运行? [英] How do you detect whether your Mixed Reality app is running on HoloLens 1, HoloLens 2 or an immersive headset?

查看:134
本文介绍了如何检测您的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(我注意到您可能基于您的标签),那么最好的方法是使用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还是沉浸式耳机上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆