You are here:   Blog
Register   |  Login

HoloLens Hello World!

Apr 2

Written by:
4/2/2016 1:08 PM  RssIcon

image

In this tutorial we will cover setting up your HoloLens development environment and creating a simple application to display Hello World!

This tutorial is primarily designed to walk you through setting up your development environment. When you run the application it allows you to move around the sphere and the Hello World text in the HoloLens or the HoloLens emulator.

Set-Up

image

Before you can begin development, you need to install the tools. This will consist of installing Visual Studio (the free “Community” version works) or updating it. Installing the HoloLens Emulator, and installing or upgrading Unity.

If you encounter any problems, consult the HoloLens Forum.

 

Create The Application In Unity

image

The first step is to create the application in Unity. You can also create HoloLens applications using only Visual Studio, however Unity provides better tools for creating 3D objects.

image

Open Unity and select New.

image

Set the Project name to HoloLensHelloWorld, ensure 3D is selected, and click the Create project button.

image

When the Unity designer loads, set the layout to Default by selecting the setting in the dropdown in the upper right-hand corner of the screen.

 

Set-Up The Camera

image

In the Hierarchy window, expand the Untitled section to reveal the Main Camera.

Double-click on Main Camera to center on it in the Scene window.

image

In the properties for the Main Camera, in the Inspector window:

  • Set the Transform / Position to: X:0, Y:0, Z:0 (so the location of the users head starts at the Unity world origin)
  • Set the Camera / Clear Flags to Solid Color (we will also set the background to black in the next step)
  • Set the Camera / Clipping Planes  to 0.85 (the recommended closest distance for holograms)

image

To set the background to black (in the HoloLens, black will appear transparent), click on the Background color bar to open the Color Picker.

image

To create the color black, set the R,G,B,A to 0 and close the Color Picker.

 

Create The Holograms

image

From the toolbar, select GameObject then 3D Object then 3D Text.

The 3D Text object will appear in the Scene.

Note: You can click on the scene and alternatively hold down the middle scroll bar on your mouse or the right mouse button and move the image around to see it better. See Unity scene view navigation.

image

Ensure that you have the 3D Text object selected in the Hierarchy window.

In the Inspector window:

  1. Set Hello World! for the object name
  2. Set X:-1,Y:0.3,Z:3.7 for Transform / Position
  3. Set X:0.25,Y:0.25,Z:0.25 for Transform / Scale
  4. Set Hello World! for the Text Mesh / Text
  5. Set Yellow for the Text Mesh / Color

 

image

From the toolbar select GameObject then 3D Object then Sphere.

The Sphere object will appear in the Scene.

image

Ensure that you have the Sphere object selected in the Hierarchy window.

In the Inspector window:

  1. Set X:0,Y:-0.1,Z:2 for Transform / Position
  2. Set X:0.25,Y:0.25,Z:0.25 for Transform / Scale

 

Save The Scene

image

From the toolbar, select File then Save Scene as…

image

Save the scene as Main (in the Assets folder).

View The Scene

image

Click on the Game tab to see the final result.

Click on the Scene tab to return to the previous designing state.

 

Quality Settings

image

The first step of the build and deploy process is to set the Quality settings.

From the toolbar select Edit then Project Settings, then Quality.

image

In the Inspector window, click on the black downward pointing selector under the column with the Windows Store icon and select Fastest.

 

Build Settings

image

To deploy to the HoloLens or the HoloLens emulator, the Unity project must be exported as a Universal Windows Platform app (UWP).

From the toolbar, select File then Build Settings.

image

In the Build Settings window:

  • Click the Add Open Scenes button to add the Main scene to the Scenes In Build window
  • Select Windows Store for Platform
  • Select Universal 10 for SDK and D3D (Direct 3D) for UWP Build Type
  • Click the Player Settings button (to go to player settings)

 

image

In the Inspector window (for player settings), click on the Windows Store icon to select its settings, and then select the checkbox next to Virtual Reality Supported (under Other Settings).

When you do this, Windows Holographic will show under Virtual Reality SDKs.

image

Return to Build Settings.

Select the checkbox next to Unity C# Projects (for more information on this setting see: exporting your project from Unity).

Click the Build button.

A Windows Explorer window will open.

image

We need to create a folder to deploy the project to. This is the folder that will contain the Visual Studio project.

In the Windows Explorer dialog, right-click in the open folder, and select New then Folder.

image

Name the folder App.

The App folder will be created.

Select the App folder, and then click the Select Folder button.

image

The project will build.

image

When it completes building, open the App folder and double-click on the HoloLensHelloWorld.sln file to open the project in Visual Studio.

image

The project will open in Visual Studio.

In the Solution Explorer, right-click on the Package.appxmanifest file and select View Code.

image

Change the TargetDeviceFamily Name setting to Windows.Holographic.

Click the Save button and close the file.

image

Set the project to Release and x86

Select the HoloLens Emulator

Note: If you have an actual HoloLens device and would like to use that instead, see these links:

image

In the Solution Explorer, ensure that you have the (Universal Windows) project selected.

image

From the toolbar, select Debug then Start Without Debugging.

image

  • You may get a message indicating that you need to enable developer mode (this box may appear behind other windows so look to see if the Visual Studio icon is flashing on the windows bar)
  • Click the Settings for developers link.

image

  • The Update & Security window will appear
  • Select Developer mode
  • Select Yes to the confirmation box that will then appear
  • Close the Update & Security window (by clicking the X in the upper right-hand corner)

image

Click the OK button.

image

The emulator will open and the project will load.

Note: It may take several minutes for the project to load the first time.

If it doesn’t load after several minutes, try selecting Start Without Debugging again.

image

The project will show.

You can use the W, A, S, and D keys to move around.

For directions on using the Emulator, see:

image

Links

HoloLens Documentation

HoloLens Documentation (All Pages)

HoloLens Forum

HoloLens - Install The Tools

Using the HoloLens emulator

Using the Windows device portal

Download

You can download the code from the Download page.


Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel