Unity 2020 Virtual Reality Projects
上QQ阅读APP看书,第一时间看更新

Choosing your target VR platforms and toolkits

While much of your development will focus on the artwork, behaviors of game objects, and interactive game mechanics of your application, from the very beginning of your project, you should also identifywhich platforms and devices you are targeting. In ordinary Unity projects, it's often sufficient to simply choose the Build Settings target platform (for example, Android or Windows) and then configure Player Settings for build runtime options. But for VR, there's more. You need to manage the VR plugins you will need and use additional toolkit(s) for developing the project. Generally, your Unity VR project will need to include the following:

  • Select a Target Platform for your builds (for example, Android versus Standalone/Windows).
  • Install an XR Plugin that drives the VR devices.
  • Within your scene, you will include a VR-enabled camera rig for tracking head and hand locations in 3D space.
  • Using other components provided with Unity's XR Interaction Toolkit for handling interaction with game objects and locomotion in your scenes.
  • Alternatively, you may choose to include device-specific toolkits, often provided by device manufacturers that have been tuned to their specific devices and often include a suite of prefabs, components, and shaders. These higher-level add-ons help you create interactive, responsive, and comfortable VR experiences tailored to a specific platform.

Unity has a growing library of built-in classes and installable packages to support VR (or rather, XR including augmented reality devices), including stereo rendering, input tracking, user interactions, and audio spatializers. Some features are limited by specific platform capabilities, but generally, they're designed to be device-independent.

I will walk you through the details of installing and configuring your project in this chapter. If you are not sure which platform, XR plugin, and device toolkit to include in your project, consult the following table, which shows many of the major consumer VR devices available today and the options for the development platform, target device platform, VR runtime, XR plugin, and optional device toolkit. The first table identifies the plugins provided and supported directly by Unity:

The following table shows plugins that have been announced but are not currently available (at the time this was written):

Note that Valve's OpenVR supports multiple VR devices, although OpenVR with Oculus or immersive Windows MR devices also require their corresponding runtime app be running in the background (Oculus Desktop or Mixed Reality Portal, respectively). Also note that, as of October 2019, Google discontinued Daydream and open-sourced the Cardboard SDK. As of December 2020, Oculus is sunsetting the Oculus Go and will stop accepting new applications in its store.

If you try to install multiple device toolkit packages in a Unity project, you may get irreconcilable errors caused by code conflicts. You can temporarily remove folders from Assets/ by renaming the offending folder with a trailing tilde ( ~) outside of Unity (for example, in Windows Explorer or macOS X Finder). For example, rename SteamVR to SteamVR~ and Unity will then ignore the folder and think it's been removed. However, note that your revision control tool (for example, Git) will still have the files.

So, let's get started by enabling VR in the project's scene.