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.

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.

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:

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.

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:

Use a really old HoloToolkit (with all the negative implications that come with that).