Multi-Platform VR Features in 2018.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!
Note: This article applies to the following SDKs: OpenVR, Oculus, WindowsMR, Daydream, and GearVR. It does not apply to PSVR.
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.
You can read up on changing build target platforms on the Build Settings page in Unity Documentation.
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.
Be sure to do your homework on each device you plan to target to identify the proper build target platform and VR SDK selection!
You can read up on enabling VR and selecting SDKs for your build in Unity Documentation’s VR Overview.
Tracked Pose Driver
Tracked Pose Driver is a nifty component that will drive a Transform’s position and rotation based on a VR device.
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.
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!
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.
If you need a greater understanding of specific devices, there are several handy tools in the InputTracking class.
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 also provides events that fire when a node is added or removed and when tracking on a node is lost or acquired.
Enabling SDK-Specific Details
Sometimes user experience concerns demand that you implement SDK-specific details. Don’t worry, we’ve got your back.
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.
private static float m_FireTriggerThreshold = 0.75f;
public static bool FireControlActive(Handedness hand)
if (XRSettings.loadedDeviceName == "daydream")
if (hand == Handedness.LEFT)
else // right hand
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.
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+
XR Input Tests is the multi-platform test project that Unity XR QA uses every day to verify these features and more.
10 코멘트코멘트 구독
코멘트를 달 수 없습니다.