Get the latest Holotoolkit from Github (and create a reusable package for future HoloLens Unity projects. Also, resolve the 'unsafe' compiler error. Building HoloLens Unity client Note: Make sure you have Unity 2017.4.4f1 LTS release with UWP tools support. These steps are unique, and specific to producing a unity client application for a HoloLens device. You can find the HoloLens Unity client sample in SamplesClientUnity.
Game programming is an entirely different paradigm for an enterprise application developer in terms of the tools, processes and patterns used. But like any other development engagement, to kick start the development phase and to reduces the learning curve, it is always helpful to have a set of pre-baked tools handy. In the world of HoloLens application development, Microsoft’s Mixed Reality Toolkit is your best companion.
The Mixed Reality Toolkit is an open source project driven by Microsoft. It is a collection of scripts and components which will help developers with initial hurdles they may face, when developing applications for Microsoft HoloLens and Windows Mixed Reality headsets. The source code for this project is shared on the Git Hub.
Importing the source code for the tool set
The Git repository for the Mixed Reality Tool set can be accessed using the following link
Following are the steps to clone the code for the toolkit into your VSTS repository
- Create a new project on the Visual Studio portal (.visualstudio.com).
- Give the project a name and chose the version control as ‘Git’
- On the landing page, pull down ‘Import a repository’ section and click on the import button.
- Type in the URL for the Git repository (https://github.com/Microsoft/MixedRealityToolkit) and click import.
- Once imported, the landing page for your repository will look like the image shown below
Exploring the source code
The best way to explore the source code for the Mixed Reality Toolkit is by trying out the example scenes. The example scenes are located under the path “Mixed Reality Toolkit/Assets/HoloToolkit-Examples” in the repository.
Following are the steps to open an example scene in unity.
- Start Unity and open the root folder of the repository which you have cloned on your disk.
- In the project explorer, navigate to the HoloToolkit-Examples folder. You should see folders with all the example scenes under this path. For this exercise, let’s try out a slider example. Navigate to “Assets/HoloToolkit-Examples/UX/Scenes” folder and double click on the ‘SliderSamples’ scene.
- You should now see the slider in the game window. Click on the play button to test the scene.
Installing the toolkit on a new unity project
The Mixed Reality Toolkit releases a unity package which can be incorporated into your HoloLens unity project. This package helps you configure your project and the scenes with default settings for HoloLens. It also populates your scene with basic objects like camera, input manager, cursor, etc; Following are the steps to download and install the unity package.
- Download the unity package from the following URL
- Once downloaded, import the package into unity
- Once imported correctly, you should see the ‘Mixed reality toolkit’ menu on your toolbar
- Use configure menu to set up the project and the scene settings.
Mixed reality toolkit comprises of a very useful collection of tools which lets you kick start a HoloLens project with a template containing basic objects and settings. I will be covering continuous integration and continuous deployment strategies for HoloLens application in my next blog post.
Are you ready to develop your first augmented reality application for HoloLens 2?
![Hololens Hololens](/uploads/1/1/9/7/119737869/265033617.png)
We got you. And the first thing we need to do is to set up your development environment.
In this guide we’ll show you step by step how to install, configure, and launch everything you need to start building awesome applications for HoloLens 2.
? Attend a free on-demand HoloLens 2 design and development workshop with setup instructions
HoloLens 2 Development Setup Overview
![Hololens Hololens](/uploads/1/1/9/7/119737869/358061094.gif)
We’ll be setting up our development environment using Unity 3D game engine and the most recent Microsoft's mixed reality headset — HoloLens 2.
If you don’t own a headset, that's not a problem: we’ll show you how to set up a HoloLens 2 Emulator so you can test your augmented reality application directly on your computer.
If you're looking for the guide on the first version of HoloLens - check this guide here.
If you have a HoloLens 2 headset and don’t need an emulator, skip directly to the “How To Set Up HoloLens 2 Project in Unity” section.
Table of Contents:
Setting Up HoloLens 2 Emulator
If you don’t have a HoloLens 2 headset, you still can develop your augmented applications as everyone else and run them on your PC using HoloLens 2 Emulator.
You can download the latest version of emulator from Microsoft website. You will need to install the most recent version of Visual Studio as well.
Here are the main requirements to run HoloLens 2 emulator on your PC:
- Windows 10 Pro, Enterprise, or Education 64-bit system
- Windows 10 October 2018 update or later
- 8 GB of RAM
- Hyper-V enabled
You can find the full list of requirements on Microsoft webpage.
Step-by Step Instructions To Set Up Hololens 2 Emulator
Below are step-by-step instruction to install Hololens 2 emulator on your PC:
- Enable Hyper-V feature through Control Panel -> Programs -> Programs and Features -> Turn Windows Feature on or off -> turn on “Hyper-V”
- Ensure that your Windows 10 is up to date with Windows 10 Fall Creator Update. This update is installed automatically with other OS updates, or manually install the updates here.
- Download and install the latest version of Visual Studio.
- Download and install Windows 10 SDK.
Note: the most stable version if Windows 10 SDK for running MR applications for HoloLens 2 is currently 10.0.18362.0 - Download or update to the latest version of Unity (currently 2019.4). The long-term support builds are preferable (currently 2019.4.X)
- Download and install the HoloLens 2 Emulator
- Download Windows Mixed Reality Toolkit from Github. Save it to a devoted folder as later we’ll be importing the toolkit directly into Unity.
How To Set Up HoloLens 2 Project in Unity
To build our HoloLens 2 application we will use Unity game engine. Follow these steps to configure and build a Unity project for HoloLens 2.
- Open Unity and create new 3D project
- Open File - Build Settings and switch the platform to Universal Windows Platform. Change the target device to HoloLens. If you are using the Unity 2019 version, make sure to change the Architecture to ARM64. Make sure your minimum platform version is set to 10.0.18362.0.Note: Don’t forget to click Add Open Scenes if you already have a project that you’re ready to build and test on your HoloLens 2 device or emulator.The rest of the settings should be configured as shown with the screenshot below. Finally, press Switch Platform.
- Let’s add Microsoft Mixed Reality Toolkit (MRTK) into our Unity project. Download the Microsoft.MixedReality.Toolkit.Unity.Foundation.2.4.0.unitypackage file from the Microsoft’s Github page.
After you finished downloading the file, open your Unity project again and click Assets - Import Package - Custom Package to locate the toolkit package on your hard drive.After you locate the file, click Import. - After you’ve imported the package into your Unity HoloLens 2 project, the following window will pop up:Make sure all three boxes below are checked and click Apply.
- Finally, let’s see if our Unity project settings are in check. Click Edit - Project Settings and change the following parameters:Player - XR Settings - check if Windows Mixed Reality is added to Virtual Reality SDKs panel. If not, add it manually using the “+” icon.After that change the following settings:Player - XR Settings - Virtual Reality SDKs - set 16-bit depth
Player - Other Settings - Rendering - uncheck Graphics Jobs - It’s time to create your augmented reality scene. Open Mixed Reality Toolkit menu in Unity and choose the Add to Scene and Configure option.This action will create two game objects within your Unity scene that are both critically important for your app to function: MixedReality Toolkit and Mixed Reality Playspace.
How To Deploy Your App on the HoloLens 2 Emulator for Testing
- After you finished building your project in Unity, locate the project folder and open the .sln file with Visual Studio.
- Select x86 or x64 build configuration
- Select HoloLens 2 Emulator as the target device for debugging
(Source) - Press F5 or Open Debug - Start Debugging to launch the emulator and deploy your application for debugging.
(Source) HoloLens 2 Emulator interface
Now you can start testing your mixed applications!
How To Deploy Your App on the HoloLens 2 Device For Testing
If you have a HoloLens 2, you need to perform a few extra steps to test your application with your headset.
- Connect your HoloLens 2 device to the computer via USB.
- Change build configuration to ARM or ARM64 in Visual Studio
- Choose Device option in the Device section
- The first time you deploy an app onto your Hololens 2 device you’ll be asked to enter a PIN code. To generate a PIN code by launching the Settings app on your device and go to Update - For Developers - Pair. Now your HoloLens 2 is paired with your computer so all the apps can be deployed automatically.
- Select Debug - Start Debugging to deploy your application and test it.
Hololens Toolkit Unity 2018
And that’s it!
Now you know how to set up the development environment for HoloLens 2 and deploy applications onto the HoloLens 2 headset or emulator.
You can start adding complex objects, animations, and scripts to enrich your augmented reality scenes and create unique business and entertaining applications.
“That’s all cool, but where can I learn to develop an actual mixed reality application?”
We got you here as well.
Hololens Unity Setup
If you want to learn more about the HoloLens 2 development process check out the HoloLens 2 Design & Development workshop where you create a fully functional MR app from scratch and test it with our expert instructors.
Hololens Unity Toolkit App
? Sign up for a free HoloLens 2 on-demand design and development workshop