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

Building for Windows Immersive MR

Microsoft's 3D media Mixed Reality strategy is to support the spectrum of devices and applications from virtual reality to augmented reality. This book and our projects are about VR. At the other end is the Microsoft HoloLens wearable AR device. The MixedRealityToolkit-Unity package that we will use includes support for both immersive MR headsets and HoloLens.

To allow your app to use a Windows immersive Mixed Reality (IMR) headset, you will use the Window Mixed Reality SDK, as follows:

  1. Configure your Unity Build Settings to target the Universal Windows Platform platform.
  2. In Player Settings, under XR Settings, set Virtual Reality Enabled
  3. Ensure Windows Mixed Reality is at the top of the Virtual Reality SDKs list.
  4. Download and install the Mixed Reality Toolkit Unity, as instructed previously.
  5. We also recommend you install its sister examples unity package from the same location.

Now we will add the MixedRealityCamera rig to the MeMyselfEye object in our scene:

  1. Look in your Project window; under the Assets folder, you should have a folder named HoloToolkit (or MixedRealityToolkit).
  2. Within that is a subfolder called Prefabs. Drag the prefab named MixedRealityCameraParent from the Assets/HoloToolkit/Prefabs/ folder into your Hierarchy. Place it as a child object of MeMyselfEye.
  3. If necessary, reset its Transform to Position (0, 0, 0).
  4. Disable the Main Camera object, also under MeMyselfEye. You can disable objects by unchecking the enable checkbox in the top-left of its Inspector window. Alternatively, you can just delete the Main Camera object.
  5. Save the prefab by selecting MeMyselfEye in Hierarchy, then press its Apply button in the Inspector.

Note that the MixedRealityCameraParent rig y position should be set to 0 as it will use the real-life height of the player to set the camera height in real time.

To test it out, make sure that the VR device is properly connected and turned on. You should have the MR Portal app opened in the Windows desktop. Click on the game Play button at the top-center of the Unity Editor. Put on the headset, and it should be awesome! Within VR, you can look all around—left, right, up, down, and behind you. You can lean over and lean in. Using the hand controller's thumb pad, you can make Ethan walk, run, and jump just like we did earlier.