Microsoft HoloLens Developer's Guide
上QQ阅读APP看书,第一时间看更新

Getting started with Unity3D

When you start up Unity, you will get a screen such as this one:

The Unity3D startup screen

If you have tried Unity before, you will have a list of recently opened projects here, but in my case, this list is empty as I start with a clean install. Click on the New project button.

Fill in the name and location you want to save the project to and click on create. Unity is file-based and thus all files and folders needed will be in one location. Ensure that you back up this location later on and store it in a repository, such as Visual Studio Team System or Git, if you want to ensure that you do not lose your sources.

You will be greeted with the standard Unity screen. This is where we will put our holograms and other assets we might need, but for now we will just set up the environment.

I have already explained how to do this in Unity in the last chapter, so I will just outline the steps you need to take here:

  1. Select the Main Camera in the Hierarchy panel.
  2. Reset the coordinates of that camera to location (0,0,0). By default, this is (0, 0, -10), meaning that the user is 10 meters away from the center. In HoloLens apps, the user is always in the center of the application.
  1. Set Clear flags to Solid Color and Background to black (RGB 0,0,0). Remember that black is transparent, and we want the user to see the real world as much as possible.
  2. In your Assets panel, right-click and create a new folder. Name this Scenes.
  3. Press Ctrl + S to save the scene in this newly created folder; name it main.
  4. Go to File | Build Settings, or press Ctrl + Shift + B to open the Build Settings screen.
  5. Click on the Add Open Scenes button to ensure that the current scene is part of the app.
  6. Click on Windows Store, and then on Switch Platform. You should see the Unity logo next to the Windows Store line to indicate that this is our current platform.
  7. Change the SDK to Universal 10.
  8. Change the UWP Build type to D3D.
  9. Check both Unity C# Projects and Development Build under debugging.

Your Build Settings screen should look like this:

The Build Settings for Holographic applications
  1. Press Player Settings...
  2. In the Inspector panel, you should see the settings. They are organized in sections, one of which is called Other Settings. Under Rendering, you will find the Virtual Reality Supported option, and this needs to be checked. You will see the options you have, but there is only one SDK supported here--Windows Holographic. So, you do not need to do anything here:
PlayerSettings for HoloLens Unity projects
  1. Now, assuming that you still have the PlayerSettings opened, press Build. If not, open the PlayerSettings dialog again.
  2. You will be asked for a location to store the Visual Studio Solution. Create a new folder called VS and select that.
  3. Unity will now build your project. This might take some time when you do it for the first time.

After the building is done, Explorer will open to show you the results. It is time to explore them in Visual Studio!