pano2vr 2.2.3_2018.3中的多平台VR功能

pano2vr 2.2.3

Targeting as many VR platforms as you can gives your application the widest possible audience. Using the Unity 2018.3 features outlined in this article, you can make a lean, mean app that works across a wide range of desktop and mobile VR devices without having to painstakingly build for each platform. Read to the end to find references to open source projects that show these features in action!

尽可能多地定位VR平台,使您的应用程序具有尽可能多的受众。 使用本文概述的Unity 2018.3功能,您可以制作一个精简,卑鄙的应用程序,该应用程序可在广泛的台式机和移动VR设备上运行,而不必为每个平台精心构建。 阅读全文,以找到开放源代码项目的参考,这些参考项目将展示这些功能的实际作用!

Note: This article applies to the following SDKs: OpenVR, Oculus, WindowsMR, Daydream, and GearVR. It does not apply to PSVR.

注意:本文适用于以下SDK:OpenVR,Oculus,WindowsMR,Daydream和GearVR。 它不适用于PSVR。

建立目标平台和VR SDK选择 (Build Target Platform and VR SDK choice)

First, the basics.

首先,基础知识。

Depending on what devices your application is built for, you may have to change your build target platform and compile multiple times. If you’re targeting the Oculus Rift, for example, your build target platform should be “PC, Mac, & Linux Standalone.”  If you are targeting Oculus Go, your build target platform should be “Android.” If you want to target both the Oculus Rift and Oculus Go, you will want to build once per each target platform.

根据构建应用程序的设备的不同,您可能必须更改构建目标平台并进行多次编译。 例如,如果您以Oculus Rift为目标,则您的构建目标平台应为“ PC,Mac和Linux Standalone”。 如果您以Oculus Go为目标,则构建目标平台应为“ Android”。 如果要同时定位Oculus Rift和Oculus Go,则每个目标平台都需要构建一次。

You can read up on changing build target platforms on the Build Settings page in Unity Documentation.

您可以在Unity文档的“ 构建设置”页面上阅读有关更改构建目标平台的信息

Under each build target platform, you must target the correct virtual reality SDK.  Sometimes you can target multiple SDKs with a single exe, and sometimes you must build separately.  When targeting “PC, Mac, & Linux Standalone” you can build targeting both Oculus and OpenVR virtual reality SDKs.  When targeting “Android” you must build separately for daydream and Oculus virtual reality SDKs.

在每个构建目标平台下,您都必须以正确的虚拟现实SDK为目标。 有时您可以使用一个exe来定位多个SDK,有时您必须单独构建。 以“ PC,Mac和Linux独立版”为目标时,您可以同时以Oculus和OpenVR虚拟现实SDK为目标。 以“ Android”为目标时,您必须为Daydream和Oculus虚拟现实SDK分别构建。

Be sure to do your homework on each device you plan to target to identify the proper build target platform and VR SDK selection!

确保在计划要定位的每台设备上完成作业,以识别正确的构建目标平台和VR SDK选择!

You can read up on enabling VR and selecting SDKs for your build in Unity Documentation’s VR Overview.

您可以在Unity文档的VR概述中阅读有关启用VR以及为构建选择SDK 的信息

跟踪姿势驱动程序 (Tracked Pose Driver)

Tracked Pose Driver is a nifty component that will drive a Transform’s position and rotation based on a VR device.

Tracked Pose Driver是一个精美的组件,它将基于VR设备驱动Transform的位置和旋转。

This screenshot shows an XR Rig that uses Tracked Pose Driver.  The “Main Camera,” “Left Hand,” and “Right Hand” GameObjects of the XR Rig each have a TrackedPoseDriver component, which will change their GameObject’s Transform based on the selected Device/Pose Source combination.  You can play with this XR Rig yourself by creating a new project using the VR Lightweight RP template.

此屏幕快照显示了使用“跟踪姿势驱动程序”的XR装备。 XR装备的“主摄像机”,“左手”和“右手”游戏对象均具有TrackedPoseDriver组件,这些组件将根据选定的设备/姿势源组合更改其GameObject的变换。 您可以使用VR Lightweight RP模板创建一个新项目来自己玩XR Rig。

输入管理器 (InputManager)

Hey, did you know that you can get input from VR controllers the same way you get input for non-VR controllers? It’s true! Using the Input Megachart available on our XR Input documentation page, you can reference input such as triggers, thumbsticks, grip buttons, and more!

嘿,您知道您可以像从非VR控制器获得输入一样从VR控制器获得输入吗? 这是真的! 使用我们的XR输入文档页面上的输入Megachart,您可以引用输入,例如触发器,指尖,握柄按钮等!

For example, here is how you set up the Input Manager for the left-hand trigger axis:

例如,以下是设置左侧触发轴的输入管理器的方法:

And here is how you setup the Input Manager for the left-hand Primary Button.

这是您为左侧主按钮设置输入管理器的方法。

XR节点 (XRNodes)

If you need a greater understanding of specific devices, there are several handy tools in the InputTracking class.

如果您需要对特定设备有更深入的了解, InputTracking类中有几个方便的工具。

InputTracking.GetNodeStates() will give you a list of what we call XRNodeStates.  XRNode types include abstract representations such as Head, LeftHand, RightHand, TrackingReference (for example, Oculus Rift cameras or Vive Lighthouses), and several more. XRNodeStates provide physical information such as position and rotation of a node.  It also tells you the node type, whether or not the node is currently tracked, and gives you a uniqueID.

InputTracking.GetNodeStates()将为您提供我们称为XRNodeStates的列表。 XRNode类型包括诸如Head,LeftHand,RightHand,TrackingReference(例如,Oculus Rift相机或Vive Lighthouse)之类的抽象表示,以及其他几种。 XRNodeState提供物理信息,例如节点的位置和旋转。 它还会告诉您节点类型,当前是否跟踪该节点,并为您提供一个uniqueID。

InputTracking also provides events that fire when a node is added or removed and when tracking on a node is lost or acquired.

InputTracking还提供在添加或删除节点以及丢失或获取对节点的跟踪时触发的事件。

启用特定于SDK的详细信息 (Enabling SDK-Specific Details)

Sometimes user experience concerns demand that you implement SDK-specific details.  Don’t worry, we’ve got your back.

有时,用户体验会涉及要求您实现特定于SDK的详细信息。 不用担心,我们已经为您服务。

XRSettings provides global XR-related settings such as which VR SDKs are supported by your built application and which one specifically is active.  XRSettings.supportedDevices lists out the VR SDKs that were selected at build time. XRSettings.loadedDeviceName tells you which SDK is currently driving input.  Using this setting, you can enable platform-specific settings such as choosing different inputs to drive user actions.

XRSettings提供了与XR相关的全局设置,例如,所构建的应用程序支持哪些VR SDK,哪些是活动的。 XRSettings.supportedDevices列出了在构建时选择的VR SDK。 XRSettings.loadedDeviceName告诉您当前哪个SDK在驱动输入。 使用此设置,您可以启用特定于平台的设置,例如选择不同的输入来驱动用户操作。

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
private static float m_FireTriggerThreshold = 0.75f;
   public static bool FireControlActive(Handedness hand)
   {
       if (XRSettings.loadedDeviceName == "daydream")
       {
           if (hand == Handedness.LEFT)
               return Input.GetButton("VR_PrimaryButton_Left");
           else // right hand
               return Input.GetButton("VR_PrimaryButton_Right");
       }
       else
       {
           if (hand == Handedness.LEFT)
               return Input.GetAxis("VR_TriggerAxis_Left") > m_FireTriggerThreshold;
           else // right hand
               return Input.GetAxis("VR_TriggerAxis_Right") > m_FireTriggerThreshold;
       }
   }

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
private static float m_FireTriggerThreshold = 0.75f ;
   public static bool FireControlActive ( Handedness hand )
   {
       if ( XRSettings . loadedDeviceName == "daydream" )
       {
           if ( hand == Handedness . LEFT )
               return Input . GetButton ( "VR_PrimaryButton_Left" ) ;
           else // right hand
               return Input . GetButton ( "VR_PrimaryButton_Right" ) ;
       }
       else
       {
           if ( hand == Handedness . LEFT )
               return Input . GetAxis ( "VR_TriggerAxis_Left" ) > m_FireTriggerThreshold ;
           else // right hand
               return Input . GetAxis ( "VR_TriggerAxis_Right" ) > m_FireTriggerThreshold ;
       }
   }

Using XRSettings along with XRNodes, you can control UX decisions across all VR SDKs and their respective devices.

结合使用XRSettings和XRNodes,您可以控制所有VR SDK及其各自设备上的UX决策。

资源资源 (Resources)

Are you excited to get your hands on the features discussed in this article? Check out these two projects to get started:

您为获得本文讨论的功能而感到兴奋吗? 查看以下两个项目以开始使用:

Onslaught is a <400kB project on GitHub that supports OpenVR, Oculus Desktop, Windows Mixed Reality Immersive Headsets, Oculus Mobile (GearVR, Go), and Daydream.  Try it now with Unity Editor 2018.3.0b3+

Onslaught是GitHub上的<400kB项目,支持OpenVR,Oculus Desktop,Windows混合现实沉浸式耳机,Oculus Mobile(GearVR,Go)和Daydream。 立即使用Unity Editor 2018.3.0b3 +尝试

XR Input Tests is the multi-platform test project that Unity XR QA uses every day to verify these features and more.

XR Input Tests是Unity XR QA每天用来验证这些功能以及更多功能的多平台测试项目。

翻译自: https://blogs.unity3d.com/2018/11/22/multi-platform-vr-features-in-2018-3/

pano2vr 2.2.3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值