Holograms 100

This tutorial will walk you through creating a basic holographic app built with Unity. This project can then serve as a starting template for any holographic app you might want to build in Unity.


Chapter 1 - Create a New Project

To build an app with Unity, you first need to create a project. A project is a folder that holds all assets you import from digital content creation tools such as Maya, Max Cinema 4D or Photoshop, all code you create with Visual Studio or your favorite code editor, and any number of content files that Unity creates as you compose scenes, animations and other Unity asset types in the editor. Unity projects do not rely on a centralized project file like Visual Studio's solution file (*.sln) - they are just based on folder structure.

Unity project script files are also not managed via a central project file (*.csproj in Visual Studio). Unity automatically discovers C# files in the project folder. To build and deploy UWP apps, Unity can export the project as a Visual Studio solution that will contain all necessary asset and code files.

  1. Start Unity
  2. Select New
  3. Enter a project name (e.g. "HelloHolograms")
  4. Enter a location to save your project
  5. Ensure the 3D toggle is selected
  6. Select Create project

Chapter 2 - Setup the Camera

The Unity Main Camera handles head tracking and stereoscopic rendering. There are a few changes to make to the Main Camera to use it with HoloLens.

First, it will be easier to lay out your app if you imagine the starting position of the user as (X: 0, Y: 0, Z: 0). Since the Main Camera is tracking movement of the user's head, the starting position of the user can be set by setting the starting position of the Main Camera.

  1. Select Main Camera in the Hierarchy panel
  2. In the Inspector panel, find the Transform component and change the Position from (X: 0, Y: 1, Z: -10) to (X: 0, Y: 0, Z: 0)

Second, the default Camera background needs to be changed. In holographic applications, the real world should appear behind everything the camera renders, not a Skybox texture.

  1. With the Main Camera still selected in the Hierarchy panel, find the Camera component in the Inspector panel and change the Clear Flags dropdown from Skybox to Solid Color.
  2. Select the Background color picker and change the RGBA values to (0, 0, 0, 0)

Finally, to prevent holograms from being rendered too close to the users eyes as a user approaches a hologram or a hologram approaches a user, the near clip plane can be set to the HoloLens recommended 0.85 meters.

  1. With the Main Camera still selected in the Hierarchy panel, find the Camera component in the Inspector panel and change the Near Clip Plane field from the default 0.3 to the HoloLens recommended 0.85.

Chapter 3 - Create a Hologram

Creating a hologram in your Unity project is just like creating any other object in Unity. Placing a hologram in front of the user is easy because Unity's coordinate system is mapped to the real world - where one meter in Unity is approximately one meter in the real world.

  1. In the top left corner of the Hierarchy panel, select the Create dropdown and choose 3D Object > Cube.
  2. Select the newly created Cube in the Hierarchy panel
  3. In the Inspector find the Transform component and change Position to (X: 0, Y: 0, Z: 2). This positions the cube 2 meters in front of the user's starting position.
  4. In the Transform component, change Rotation to (X: 45, Y: 45, Z: 45) and change Scale to (X: 0.25, Y: 0.25, Z: 0.25). This scales the cube to 0.25 meters.
  5. To save the scene changes, select File > Save Scene, name the scene, and select Save

Chapter 4 - Export from Unity to Visual Studio

The Unity work on HelloHolograms is now complete, so the project is ready to be exported to Visual Studio and then to your HoloLens.

Unity performance settings

Unity quality settings
Unity quality settings
Since maintaining high framerate on HoloLens is so important, we want the quality settings tuned for fastest performance. For more detailed performance information, Performance recommendations for Unity.

  1. Select Edit > Project Settings > Quality
  2. Select the dropdown under the Windows Store logo and select Fastest. You'll know the setting is applied correctly when the box in the Windows Store column and Fastest row is green.

Unity build settings

We want to specify our Unity project to export as a Universal Windows Platform app.

  1. Select File > Build Settings...
  2. Select Windows Store in the Platform list.
  3. Set SDK to Universal 10
  4. Set Build Type to D3D.

Specify the export for Windows Holographic

We need to let Unity know that the app we are trying to export should create a holographic view instead of a 2D view. We do that by adding HoloLens as a virtual reality device.

  1. From the Build Settings... window, open Player Settings...
  2. Select the Settings for Windows Store tab
  3. Expand the Other Settings group
  4. In the Rendering section, check the Virtual Reality Supported checkbox to add a new Virtual Reality Devices list and confirm "Windows Holographic" is listed as a supported device.

Export the Visual Studio solution

Now your Unity project has all the settings applied to be properly exported as a Visual Studio solution for a HoloLens app.

  1. Return to the Build Settings window.
  2. Click Add Open Scenes to add the scene
  3. Check Unity C# Projects under "Windows Store" build settings.
  4. Click Build
  5. Click New Folder and name the folder "App".
  6. With the App folder selected, click the Select Folder button.
  7. When Unity is done building, a Windows File Explorer window will appear.
  8. Open the App folder in File Explorer.
  9. Open the generated Visual Studio solution (HelloHolograms.sln in this example)

Target the app to Windows.Holographic

By default, Universal Windows Platform apps exported from Unity will run on any Windows 10 device. For Holographic applications, we are taking advantage of some features that are only available on HoloLens. If you aren't building in fallback behavior for non-HoloLens devices, it's best to target the app to only run on Holographic devices.

  1. In Visual Studio, right click on Package.appxmanifest in the Solution Explorer and select View Code
  2. Find the line specifying TargetDeviceFamily and change Name="Windows.Universal" to Name="Windows.Holographic".
  3. On the same line, change MaxVersionTested="10.0.10240.0" to MaxVersionTested="10.0.10586.0"
  4. Save the Package.appxmanifest.

Chapter 5 - Build and Deploy

All that's left is to build the Unity exported project, deploy it, and try it out on the device.

  1. Using the top toolbar in Visual Studio, change the target from Debug to Release and from ARM to X86.

Now the instructions differ for deploying to a HoloLens versus the emulator. Follow the instructions that match your setup.

HoloLens over Wi-Fi

  1. Click on the arrow next to the Local Machine button, and change the deployment target to Remote Machine.
  2. Enter the IP address of your HoloLens device and change Authentication Mode to Universal (Unencrypted Protocol).
  3. Select Debug > Start without debugging. If this is the first time deploying to your device, you will need to pair it with Visual Studio.

HoloLens over USB

  1. Click on the arrow next to the Local Machine button, and change the deployment target to Device.
  2. Select Debug > Start without debugging


  1. Click on the arrow next to the Device button, and select HoloLens Emulator.
  2. Select Debug > Start without debugging

Try out your app

Now that your app is deployed, try moving all around the cube and observe that it stays in the world in front of you.

See also