Last Updated: Aug 27, 2017
- Setup the HoloLens development tools
- Create the project
- Install the MixedReality Toolkit
- Setup the project setting for HoloLens
- Build and deploy to the HoloLens and/or the emulator
Getting the development tools has become very easy in recent months. You should have Hyper-V enabled on your O/S to run the emulator. Developing in Windows 10 is highly recommended, so if you haven’t upgraded yet to Windows 10 now is the time. Microsoft has a great page here that has links to install everything needed to begin HoloLens development. Basically it amounts to:
- Enable Hyper-V in your O/S through Control Panel -> Programs -> Programs and Features -> Turn Windows Features on or off
- Install Visual Studio 2017 15.3.2
- Install the HoloLens Emulator
- Install the Unity 2017.1.0p5
Start Unity and select New project. Name your project, select 3D for the type and select a location for the new project. This image shows the settings I used to create this project.
Click Create project. The Unity Editor should display containing your empty project.
The Unity MixedRealityToolkit is available on GitHub. There are older parts of the toolkit in the HoloAcademy tutorials, which you should avoid using! I would urge you to check out the HoloAcademy tutorials, the concepts are still very valid and it is a helpful foundation, but the MRToolkit parts are old and outdated and create confusion for new developers.
- Go to https://github.com/Microsoft/MixedRealityToolkit-Unity/releases/ and download the current release.
- Switch to Unity and Select Assets -> Import Package -> Custom Package.
- Select the UnityPackage that you downloaded and Click Import all.
- Wait, this will take a while.
When complete your project should now look like this:
Notice that in the project pane the assets folder now contains the HoloToolkit folder and three other files. These three extra files that look like junk are actually configuration files for Unity that configures some advanced settings to allow the interop to work correctly. You must leave these files in place for your project to build correctly. The folder is called HoloToolkit for legacy reasons, this will change in a future release of the MRToolkit.
Unity Project Configuration
A default unity project opens an unsaved scene with a main camera and a directional light. In this section we are going to modify the scene to work with HoloLens. Start by deleting “Main Camera” from the Hierarchy. In the project pane navigate to the Assets/HoloToolkit/Input/Prefabs folder and select HoloLensCamera. Similar to the picture below:
Drag the HoloLensCamera prefab into the Hierarchy. Leave the Directional Light in the scene. This light is not ideal, but is good for this tutorial. For a real project you would want to add numerous lights to create the correct atmosphere, but I’ll save that for another tutorial.
From the File Menu select Save Scene. Create a new folder in “Assets” called “Scenes” and save the scene inside that folder with a name of your choosing. I will call mine “tutorial”. Your Unity project should now look like this:
Notice that the top node in the Hierarchy is the name of your open scene.
Building for HoloLens
Before we can build the HoloLens project, we need to configure some Unity settings. From the HoloToolkit Menu select “Apply HoloLens Project Settings”. You will see a dialog box asking if the wizard can enable text serialization click Yes. Allow the project to reload.
What just happened?!?
- The Project QualitySettings were just set to “Fastest” for Windows Store Apps.
- The Build Settings were set to Windows Store App, SDK Universal 10, Build Type D3D
- The Project PlayerSettings were set to enable the Virtual Reality SDK “Windows Holographic”
Select the File, Build Setting menu. You should see the following dialog:
Click Add Open Scenes. For Target Device select HoloLens. Make sure to select “Development Build” and Unity C# project. The tells Unity to enable debug hooks that can be used later for profiling and to create the c# projects that you will build in visual studio.
Click Build and Create a folder in the root of your project directory called “App” and select that folder. Once the build completes successfully a Windows file explorer Window is displayed that shows the root folder of your project. Open the App folder and open the SLN that was created there.
This solution is a ready to build HoloLens App!
Deploy to HoloLens
In the VS toolbar set the Solution Configuration to Release and the Solution Platform to x86. For Build Target select Remote Device. You will see this configuration screen:
If everything goes well you will see your HoloLens listed as Auto Detected. Simply select it. If not on your HoloLens say “Hey Cortana, What is my IP Address” and enter the address, leaving authentication mode set to Universal. Click Debug, Start Debugging. Your project will build and deploy to the HoloLens, you should see a Unity Logo, followed by nothing because we have not implemented anything. Press Stop in Visual Studio closing the application on your HoloLens.
Deploy to Emulator
In the VS toolbar set the Solution Configuration to Release and the Solution Platform to x86. For Build Target select HoloLens Emulator. Click Debug, Start Debugging. Your project will build and deploy to the HoloLens Emulator, you should see a Unity Logo, followed by nothing because we have not implemented anything. Press Stop in Visual Studio closing the application on the Emulator. To learn more about the emulator visit the Hololens Emulator reference.
Tutorial IndexVersions: Unity 2017.1.0p5 | MixedRealityToolkit-Unity v1.2017.1.0 | Visual Studio 2017 15.3.2
|Unity 3D Project Creation||How to create a HoloLens project in Unity 3D|
|Source Control||Configure git for HoloLens / Unity work|
|Spatial Mapping||How to spatial map a Room|
|Object Surface Observer||Set up fake spatial map data for the Unity editor|
|TagAlongs and Billboarding||Tag along instructions to the user to force text on screen|
|Spatial Understanding||Add spatial understanding to get play space detail|
|Finalizing Spatial Understanding||Complete Spatial Understanding and Input Manager|
|Object Placement and Scaling||Find valid locations for holograms in the play space|
|Hologram Management||Manage the holograms you want to place in the world|
|Cursor and Voice||Add a cursor and voice commands|
|Occlusion||Add occlusion with the real world to your scene|
|Colliders and Rigidbodys||Add Colliders and RigidBodys to your holograms|