How to Set Up Your HoloLens in Developer Mode for Unity and Build AR Apps

Last Updated: January 14 2019

HololensUnity

This Unity tutorial will take you through step-by-step so you can start developing for HoloLens. Once your device is ready in developer mode, you can start building your own augmented reality application in Unity.




Skip to the Technical Steps


Setting Up and Testing on a HoloLens Emulator

If you don’t have a HoloLens, you’ll want to download an emulator so you can test your application as you build.

The HoloLens emulator runs through Visual Studio. You can download the emulator here, and Visual Studio here. Note that the emulator will not work on Windows 10 Home OS. You’ll need Windows 10 Pro, Enterprise, or Education. You can check your system OS in your Settings window under ‘About’.

If you don’t want to setup the emulator, you can skip ahead to setting up a Unity project for HoloLens.

To setup your HoloLens Emulator:

It's possible to develop for the HoloLens without actually owning one. But, you'll need to download the emulator for testing purposes. Here's how:

  1. Head into your Control Panel, and navigate to Programs, then Programs and Features. Click on the link on the left-hand side labeled Turn Windows Features On or Off. In the pop-up window, enable Hyper-V.
  2. Make sure your Graphics Card is up to date. You can update your driver using Device Manager. Navigate to Start, to Device manager, then to Display Adapters. Select your Graphics Card, and the option to Update Driver.
  3. We’ll want to ensure the Windows 10 Fall Creator Update is installed. It should have occurred automatically in your normal OS updates. To install manually follow this link and the instructions on the screen.
  4. Confirm that you have the latest version of Visual Studio installed. You can find the latest version here.
  5. Install the Windows 10 SDK at this link here.
  6. Install or Update to the latest version of Unity (Unity 2017.4 or above). You’ll want to confirm that you have the following components selected: Windows Store .NET Scripting Backend; Windows Store IL2CPP Scripting Backend; and Vuforia Augmented Reality Support.HoloLens Unity Download Components

  7. Download the HoloLens Emulator here.
  8. Lastly, download the Windows Mixed Reality Toolkit from the GitHub repository here. As you might know, you’ll be downloading a lot of SDKs and Toolkits throughout the development process so it’s a good idea to have a special folder where you’ll save and store them.


Setting up Unity to Start Developing for HoloLens

After finishing download the programs you need to run your emulator, you’re ready to get started in Unity.

    1. Open Unity and create a new 3D project
    2. Navigate to File and into your Build Settings and confirm the settings are as follows (pictured below): Your platform is set to Universal Windows Platform, with your Target Device set to HoloLens, Build Type as D3D, SDK and Visual Studio set to Latest Installed, and that you’re set to Build and Run on Local Machine. Once you’re set, select Switch Platform.HoloLens Unity Build Settings

    1. Select Player Settings and navigate to XR Settings, then add your Mixed Reality SDK
    2. Head back to Player Settings and navigate to Other Settings, and confirm your Configuration is as pictured below:HoloLens Unity Configuration

    1. Navigate to Publishing Settings and then to Capabilities. We’ll want to enable InternetClient, Microphone, and SpatialPerception.
    2. If you haven’t already, download the Windows Mixed Reality Toolkit here.
    3. We’ll bring the HoloToolkit folder from the Mixed Reality Toolkit into Unity. First, we’ll unzip the Windows Mixed Reality Toolkit. Open your Unity Assets folder and drag the HoloToolkit folder into the Project’s Assets folder. Once linked, the Mixed Reality Tab should appear on the top of your Unity menu bar alongside File, Edit, GameObject, etc.HoloLens Unity Mixed Reality Toolkit Tab

    1. Now navigate to Mixed Reality Toolkit menu to Configure and Mixed Reality Project Settings. Confirm you have the following checkmarked, then select apply.HoloLens Mixed Reality Project Settings in Unity

  1. You’re doing great! We’ll head back into Unity’s main window, and delete the default camera from your hierarchy tab. Along the bottom window navigate to HoloToolkit > Input > Prefabs and drag your HoloLensCamera into your hierarchy tab. Save your scene!
  2. Lastly we’ll navigate to File and to Build Settings, select Open Scenes, and Build into a separate folder.HoloLens Unity Build Settings



You’re now ready to start developing in Unity! But before hitting play, let’s confirm the HoloLens emulator is working with your Unity project. If you’re deploying your app onto an actual HoloLens device, we have instructions for you here.

Download our 10-week XR Development with Unity Course Syllabus



Deploying your app onto the HoloLens Emulator for testing

To make sure the emulator is working, let’s add a 3D Object into your scene. You can do this in Unity by right-clicking on the Hierarchy tab and selecting a 3D Object, let’s say a 3D rectangle. Then save and close Unity.

    1. Open your .sln project into Visual Studio. Set the Debug settings as shown below. If you have the emulator setup correctly, you should be able to see the option in the dropdown menu on the right.


      HoloLens emulator debug settings
  1. Navigate to the Debug menu and select Start Debugging. This should bring up the emulator.
  2. Users navigate HoloLens applications using hand gestures. In an emulator, we use keys to simulate these gestures. The F2 key acts as the “Bloom” gesture. The enter key works as the “Air Tap” gesture. You can move around the computer mouse to emulate the “Gaze” interaction. Using these keys, open your application and it should load similar to what’s below:


    HoloLens emulator Example

Great job! You can now test, (re)build, and test again and again until you’re confident in your application.


Deploying your app onto the HoloLens for testing

If you are testing your application on an actual HoloLens instead of an emulator, there’s a few extra steps to ensure your HoloLens is setup in Developer Mode.

    1. Enable Developer Mode on your desktop by navigating to your Settings, selecting Updates and Security, and clicking For Developers on the menu to your left. Confirm Developer Mode is on, and enable remote diagnostics and authentication, as seen below:


      configuring HoloLens into Developer Mode

  1. Next, connect your HoloLens to your computer through its USB cord. When you start your HoloLens, you’ll want to re-open your desktop’s Settings window, head into Updates and Security, For Developers, and turn Developer Mode ON for your HoloLens.
  2. Now we’ll pair your HoloLens with your computer. Your computer will ask for a Pin that you’ll generate on your HoloLens. Scroll down to Device Portal and click Pair to Generate Pin. Activate bluetooth on your HoloLens.
  3. Pair HoloLens with your computer through your Settings window, to Devices, and selecting Add Bluetooth or Other Device. This is when you’ll need to input your HoloLens pin.
  4. You’re almost there! After the pairing completes, open the project as .sln in Visual Studio. Configure the Debug settings as shown below, then navigate to the Debug menu and Start Debugging.


    HoloLens Deploy App Debug Settings

The application should now show up on your HoloLens. Once you do this, you can even start your application on HoloLens directly by running on Unity.

Help! HoloLens Troubleshooting

Don’t panic! In some cases, you may need to select Release instead of Debug. If Start Debugging gives an error saying you need to deploy the app first, navigate to Build in the menu bar and deploy from there instead. Other deployment errors are often fixed by deleting your .sln file and rebuilding from within Unity, but hopefully it doesn’t come to that!

Whether you’re building for augmented or mixed reality, Microsoft HoloLens is a great device to work with. Now that you’re setup, you’re ready to get building. Check out our programming guides for further resources.

Tired of learning on your own, download our syllabus and see how we can help you build a working prototype in just 10-weeks through small classes, live online training, and one-on-one sessions with instructors.

Download our 10-week XR Development with Unity Course Syllabus


Technical Steps:

Emulator Setup:

  1. Go to Control Panel > Programs > Programs and Features > Turn Windows Features On or Off, then enable Hyper-V
  2. Update Graphics Card
  3. Install Windows 10 Fall Creator update here
  4. Install/update Visual Studio here
  5. Install Windows 10 SDK here
  6. Install/update Unity and confirm you have selected:
    1. Windows Store .NET Scripting Backend;
    2. Windows Store IL2CPP Scripting Backend; and
    3. Vuforia Augmented Reality Support
  7. Download HoloLens emulator here
  8. Download Windows Mixed Reality Toolkit from GitHub here

Basic Unity Setup for HoloLens:

  1. Startup Unity and create new 3D project
  2. Go to File > Build Settings and change settings to below, select Switch Platform
    1. Universal Windows Platform
    2. Target Device set to HoloLens
    3. Build Type set to D3D
    4. SDK set to Latest installed
    5. Visual Studio Version set to Latest installed
    6. Build and Run on Local Machine
  3. Go to Player Settings > XR Settings and add Mixed Reality SDK
  4. Go to Player Settings > Other Settings and change Configuration to:
    1. Scripting Runtime Version set to Stable (.NET3.5 Equivalent)
    2. Scripting Backend set to .NET
    3. API Compatibility Level set to .NET
    4. Accelerometer Frequency set to 60 Hz
  5. Go to Publishing Settings > Capabilities and have checkmarked:
    1. InternetClient
    2. Microphone
    3. SpatialPerception
  6. Download Windows Mixed Reality Toolkit here if not already downloaded
  7. Unzip Mixed Reality Toolkit; import HoloToolkit into Project’s Asset folder; Mixed Reality Toolkit will now appear in Unity menu bar
  8. In Unity, navigate to Mixed Reality Toolkit menu bar > Configure > Mixed Reality Settings and select:
    1. Target Windows Universal UWP
    2. Enable XR
    3. Build for Direct3D
    4. Use Toolkit-specific InputManager axes
    5. Enable .NET scripting backend
  9. Delete default camera in hierarchy tab; add HoloLensCamera into hierarchy tab from HoloToolkit prefabs folder
  10. Save scene; go to Build Settings > Add Open Scenes > Build into a separate folder

Deploying and Testing App on Emulator:

  1. Open .sln project in Visual Studio. Set Debug settings to x86 and HoloLens emulator in drop down menu.
  2. Go to Debug > Start Debugging to bring up emulator
  3. F2 key acts as “Bloom” gesture; Enter key acts as “Air Tap” gesture; mouse acts as “Gaze” interaction. Use these keys to open app.

Deploying and Testing App on HoloLens:

  1. Enable Developer Mode on Computer:
    1. Navigate to Settings > Updates and Security > For Developers, and enable Developer Mode, remote diagnostics, and authentication
  2. Connect HoloLens to Computer
  3. Once HoloLens is connected, on computer go to Settings > Updates and Security > Developer Mode > For Developers > Turn Developer Mode ON
  4. Pair HoloLens to Computer:
    1. Navigate to Device Portal > Pair > Generate Pin
    2. Activate bluetooth with HoloLens at Settings > Devices
    3. Pair HoloLens to Computer via Settings > Devices > Add Bluetooth or Other Device. Input HoloLens Pin when prompted
  5. Open project .sln in Visual Studio. Set Debug settings to x86 and Device in drop down menu

HoloLens Deployment Troubleshooting:

  1. May need to select Release instead of Debug
  2. If Start Debugging gives error saying you need to deploy app first, go to Build menu and deploy from there
  3. Delete .sln file and rebuild in Unity

AUTHOR

SARAH ROWE

Marketing Producer

Receive our newsletter to stay on top of the latest virtual reality and augmented reality info.