How to set up HoloLens Spectator View, Part 4 – Preparing SpecatorView Packages

Getting Spectator View to run with your own app is obviously the most important step. How to include the required tools – including Sharing – into your app using the latest versions?

More specifically, I’ll add Spectator View to my playground project, which is mainly for placing a hologram in the room (with a few other useful scripts). Currently, this hologram is a nice, life-size skeleton from the Unity asset store.

HoloToolkit-Unity & Holographic Academy

The Holographic Academy course 240 explains how to set up your project to include Shared Holograms. It’s a good idea to work through the tutorial, as it will show you some of the basics of what is needed for Spectator View.

However, as with most of the Academy tutorials, it’s quite old. The HoloToolkit has evolved since then, and the demos often have little resemblance to what your project would look like if you start from scratch.

Therefore, for your own project, first clone the HoloToolkit-Unity GitHub repository to your local PC. Open the project in Unity and export the Assets folder to a new package according to the instructions.

Once this is finished, import your newly made, fresh HoloToolkit-Unity package into your own Unity project. Alternatively, you can of course use one of the pre-packaged HoloToolkit-Unity releases, which is slightly older, but is usually a good compromise.

Building the SpectatorView Unitypackage

After this step is done, the Spectator View instructions state to import also the SpectatorView_%number%.unitypackage  to our project. This is part of the HoloLensCompanionKit repository, not of the HoloToolkit-Unity.

There is a package in the repository that should always be up-to-date against the latest HoloToolkit. However, it wasn’t updated beyond the initial release (at the time of writing) and is therefore 2 months old (based on HoloToolkit 1.5.5.0).

For HoloLens, it’s usually the best to take the latest HoloToolkit code. The HoloToolkit is evolving rapidly, and the previous 2 months have seen a lot of bug fixes.

So, how to build the SpectatorView Unity package using the latest HoloToolkit sources? Let’s see what is inside the SpectatorView_1_5_5_0.unitypackage  file. If you rename it to .zip , you can open it with your favorite archive manager. By looking at the included pathname files, you can get the original filename that is included. For example, the following folder would be in the unitypackage Assets/Addons/HolographicCameraRig/Plugins/WSA

It turns out that the Unity package contains the HolographicCameraRig, which is only part of the SharedHolograms sample in the SpectatorView GitHub repository. For us this means that we need to take a part of the sample and put this into our custom project.

Therefore, let’s export the latest version from that part of the SharedHolograms sample into another Unity package. Open that in Unity, right-click on HolographicCameraRig and choose Export package…

Make sure you only export that single asset folder, not all the assets from the sample:

In the folder of that package, you will see several TODO.txt files from Microsoft. These remind us that we will need to copy the compiled DLL files of the Compositor to our project as well.

Compositor DLL files

We have already compiled the Compositor in the previous step. Now, we just need to copy the DLL files to our own project. As my custom project of course isn’t inside the folder structure of the SpectatorView GitHub repository, we need to be careful as for the parameters to provide for the CopyDLL.cmd batch file in the main folder of the repo.

Looking at the source of the batch file, we see that the copy commands expect the path of the assets folder of our own project as parameter:

Simply specifying the absolute path worked fine for me:

Next, restart Unity and open our project once again.

The TODO.txt file from the HolographicCameraRig specifies as the next step to replace CalibrationData.txt with our own file. So, we’ll copy our calibration data file that we created in Step 3 directly into the Assets folder of our own project.

Adding the Spectator View

Now, let’s slowly get to the exciting part: actually adding the spectator view to our project. Drag the Assets > Addons > HolographicCameraRig > Prefabs > SpectatorViewManager prefab to our Hierarchy panel.

Unfortunately, this results in a compile error. The spatial mapping code in the HoloToolkit apparently had a breaking change during the last two months that wasn’t updated in the Spectator View so far.

So we have two options:

  1. Use a really old HoloToolkit (with all the negative implications that come with that).
  2. Fixing the Spectator View to work with the latest HoloToolkit.

We’ll continue our journey to Spectator View in an our own project in the next part of the blog series!

HoloLens Spectator View blog post series

This post is part of a short series that guides you through integrating HoloLens Spectator View into your own Mixed Reality app:

  • Edward Silverton

    Where it says:

    “Make sure you only export that single asset folder, not all the assets from the sample”

    I’m exporting everything under HolographicCameraRig, but when importing into my project I’m not able to check Prefabs or Resources:

    https://uploads.disquscdn.com/images/76e405d9ecaeb1106b19f74b3fe0e1f9d47607a83725b422801e00a093903476.jpg

    Is this the correct behaviour?

    • Andreas Jakl

      Just tested that part again. Could it be that you already have these components in your project / that you have imported the holographic camera rig before? If yes, try deleting the HolographicCameraRig from your project, import again and select all the checkboxes to import everything.