Configuring a Unity project for HoloLens

Let's start from the top; our first task is setting up Unity and developing HoloLens applications. In this section, we will walk through setting up Unity, create a simple scene, and finally; deploy it to the emulator and device to ensure that everything is set up correctly.

At the time of writing, you will need to use Unity HoloLens Technical Preview or Unity Beta 5.5b9 or greater; you can find details at the official Unity site, http://www.unity.com. In addition, it would be useful to download and install the HoloLens emulator, which can be downloaded from http://go.microsoft.com/fwlink/?LinkID=823018. Lastly, ensure that you have Visual Studio 2015 with Update 3 installed.

Once downloaded and installed, launch Unity and create a new 3D project, as shown in the following screenshot:

After clicking on the Create project button, you will be presented with an empty Unity workspace, and now the fun begins. Introducing Unity is beyond the scope of this book. I hope to cover enough for you to work through the examples within this book, but would recommend Unity 5.x By Example by Alan Thorn to get a more rounded and comprehensive introduction to Unity.

Start by importing the PaperHoopShootAssets_START.unitypackage Unity package; you can import the assets either by double-clicking on the package or within Unity via the Assets | Import | Custom Packages menu. This will bring up the Import dialog from Unity, as in the following screenshot:

Click on Import to bring the assets into your project.

It's worth taking a moment to appreciate the minimal number of assets needed for our game; developing MR experiences allows us to borrow from the real world.

With our assets now imported, let's turn our attention to configuring Unity for HoloLens. Open the Build Settings dialog, as illustrated, via the File | Build Settings menu:

Configure the Build Settings to resemble what is presented in the preceding screenshot:

  • Set Platform to Windows Store
  • Set the SDK to Universal 10
  • Set UWP Build Type to D3D
  • Check Unity C# Projects
  • Check Development Build

Commit these changes by clicking on the Switch Platform button; then, click on the Player Settings... button to open the Player Settings dialog, where we will continue configuring Unity for HoloLens.

Expand the Other Settings pane and make the following changes:

  • Check Use 16-bit Depth Buffers
  • Check Virtual Reality Supported

Checking Use 16-bit Depth Buffers forces Unity to use a 16-bit depth buffer instead of a 24-bit buffer. This reduces the amount of data pushed between the CPU and Graphics Processing Unit (GPU), which improves performance and reduces power consumption; however, because it reduces the resolution of the depth that can be captured in your scene, it can cause Z-fighting for objects that are tightly clustered together.

Z-fighting is when two or more primitives have similar or identical values in the depth texture, causing flicking when rendered.

Checking Virtual Reality Supported makes the associated libraries available; once checked, you should see Windows Holographic become visible in a list directly below it.

We now need to declare the capabilities we need; expand the Publisher Settings pane of the Player Settings panel and check the SpatialPerception, Microphone, and InternetClient capabilities. The following table, taken from the official HoloLens documentation, shows the relevant capabilities and their associated APIs:

Capability

APIs requiring capability

WebCam

PhotoCapture and VideoCapture

SpatialPerception

SurfaceObserver and SpatialAnchor

Microphone

VideoCapture, DictationRecognizer, GrammarRecognizer, and KeywordRecognizer

InternetClient

DictationRecognizer (and to use the Unity Profiler)

PicturesLibrary/VideosLibrary /MusicLibrary

PhotoCapture and VideoCapture (for still photos, video, and audio, respectively)

 

As HoloLens is a mobile device, it requires the same considerations for balancing power consumption and performance.

The easiest way to ensure that you deliver an adequate experience is to update your projects setting to Fastest; to do this, open the QualitySettings dialog via Editor | Project Settings | Quality, and set the level to Fastest, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.66.13