How to add a 3D app launcher to your Mixed Reality app right out of Unity

Dino Fejzagić
Sep 19, 2018 · 3 min read
3D App Launcher for Microsoft’s RoboRaid game

When the Windows Mixed Reality platform was introduced a couple of applications had these really cool 3D app launchers you could place somewhere in the mixed reality world and launch the app when selecting them. Unfortunately back then, there was no way for developers to use this feature for their own applications. Luckily those days are gone, Microsoft introduced new APIs in the 2017 Fall Creators Update (RS3) for their immersive headsets. Since April 2018 Update (RS4) even HoloLens devices can use them.

As you might know, most of the Windows Mixed Reality appilcations out there are made using the Unity Engine. Once you are done developing and want to deploy to a device, you’re going to do a Unity build which will create a Visual Studio Solution for us targeting the Universal Windows Platform. All good so far. Now if you’ve read through the 3D app launchers documentation you’ll notice that in order for them to work, there is some changes we need to do to the Visual Studio project file and the appmanifest file for them to work. This is where things get complicated, since those changes are gone when you create a new Unity build in a different folder or build your app using continuous integration somewhere in the cloud. So let’s fix this by creating a Unity post build script to do the required changes for us whenever we build. Credit for most part of the code goes to Edd Smith, Head of Creative Tech at Fracture Reality. I applied some minor tweaks to get it working with IL2CPP scripting backend.

First, we’ll create scriptable object to conveniently hold our 3D launcher data. So create a folder 3DLauncher in your Unity project Assets folder. Then create a new Script file and name it AppLauncher3D. Insert the following code:

Once Unity has compiled the script, you’ll get a new menu item in the Editor Assets menu under Assets->Create->3D App Launcher. Next create a new folder Editor in your 3DLauncher folder and create another script file in it, name it AppLauncher3DEditor. This script is going to use the UnityEditor namespace, that’s why it must be inside a folder called Editor, so it’s not included when building for the target platform. Anyway, here’s the code:

Let’s break this into smaller pieces:

This is our entry point. Since we added the PostProcessBuild attribute to this static method, Unity will execute it, once it has finished building the UWP solution and give as the path to the exported project. Since Unity will do this, even when not targeting the UWP platform, we have to make sure, we are targeting it. Then we lookup the AppLauncher3D asset we created to read the configuration from it. Remember it contains the path to the .glb file and eventually overrides bounding box and center.

This is where we peform the 3 steps necessary for the 3D launcher to work:

  1. Add the required definition to the package manifest
  2. Add the asset to the project and mark is as deployment content
  3. Copy the .glb file into the projects assets folder

I’ll leave it up to you to dig into the specific methods and discover them!

And we’re done! Go ahead and create a .glb file for your 3D launcher, then add it to your Unity project assets and create the scriptable object asset to configur it. Build your project and you’ll have a shiny new 3D app launcher!

medialesson

We help our customers design, architect, develop and operate modern, intelligent, beautiful and usable apps on any platform powered by the Cloud, IoT and AI.

Dino Fejzagić

Written by

Software Developer @ medialesson GmbH, Indie Game Developer

medialesson

We help our customers design, architect, develop and operate modern, intelligent, beautiful and usable apps on any platform powered by the Cloud, IoT and AI.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade