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

Unity VR Support and Toolkits

Generally, as a developer, you spend your time working on your project scene. As we did for the diorama in the previous chapter, you'll add objects, attach materials, write scripts, and so on. When you build and run your project, the scene is rendered on a VR device and responds in real time to head and hand motions. The following diagram summarizes this Unity system VR architecture:

Within your scene, you may include a camera rig and other higher-level toolkit prefabs and components. All device manufacturers provide toolkits that are tuned to their specific devices. At a minimum, this includes the Unity Camera component for rendering the VR scene. It probably also includes a whole suite of prefabs and components, some required and some optional, which really help you create interactive, responsive, and comfortable VR experiences. We will go into detail throughout this chapter on how to set up your scene with these specific devices.

Unity has a growing library of built-in classes and components to support VR—what they call XR—and also to include augmented reality. Some are platform specific. But some are device independent. These include stereo rendering, input tracking, and audio spatializers, to name a few. For details, see the Unity Manual pages for UnityEngine.XR and UnityEngine.SpatialTracking (https://docs.unity3d.com/ScriptReference/30_search.html?q=xr).

At the lower level, any Unity project that runs on VR must set up the XR Player Settings with Virtual Reality Supported, and identify the specific low-level SDK the application should be used to drive the VR device. We will go into detail throughout this chapter on how to set up your project for specific devices.

So, as you can see, Unity is sandwiched between the app-level toolkit components and the device-level SDK. It provides a device-independent glue between device-specific API, tools, and optimizations.

Strategically, the team at Unity Technologies is dedicated to delivering a unified development platform for 2D, 3D, VR, and AR games and apps. Important new components are under development at Unity (and may already be available by the time you read this book) including the VR Foundation Toolkit and new input system. These are not covered in this book.

Before jumping in, let's understand the possible ways to integrate our Unity project with virtual reality devices. Software for the integration of applications with VR hardware spans a spectrum, from built-in support and device-specific interfaces to device-independent and platform- independent ones. So, let's consider your options.