How to create a hologram in Android (MRTK + Unity)

Today I want to present how to create a mixed reality app for Android using MRTK and Unity. After several days of reading a lot of articles and documentation about MRTK, I summarized in these steps a simple way to get a hologram running in your Android device. I hope this is useful for you!

Before going deep into this tutorial, let’s check the prerequisites to build this app:

  • OS: Windows 10
  • IDEs
    • Visual Studio 2019 with the “Game development with Unity” module
    • Unity (v2019.2.17f1) with the following modules:
1
  • Mixed Reality Toolkit 2.2.0 unity packages (you can download them here):
    • Microsoft.MixedReality.Toolkit.Unity.Foundation.2.2.0.unitypackage
    • Microsoft.MixedReality.Toolkit.Unity.Providers.UnityAR.2.2.0.unitypackage

Once these are installed, we can start working!

First of all, we are going to create a new Unity project. In order to do that, open unity hub and select new:

2

On the next screen select a 3D project, a name and folder to save it:

3

Now, go to File → Build Settings and switch the platform to Android:

4

On Player Settings, go to Settings for Android → Other Settings and remove Vulkan from Graphic APIs list.

5

For the next step, we have to import the MRTK packages:

  • Microsoft.MixedReality.Toolkit.Unity.Foundation.2.2.0.unitypackage
  • Microsoft.MixedReality.Toolkit.Unity.Providers.UnityAR.2.2.0.unitypackage
6

And apply all default settings on this project:

7

Also we must add these packages from Windows → Package Manager

  • AR Foundation 2.0.2
  • ARCore XR Plugin 2.0.2
  • XR Legacy Input Helpers 1.0.0
  • Multiplayer HLAPI 1.0.4

Restart Unity to load all this new packages.

Once it has restarted, we need to configure MRTK in our scene. In order to do that, go to Mixed Reality Toolkit → Add to Scene and Configure. Doing this will add two components in our scene

8

Let’s select the new component MixedRealityToolkit and configure it on the Inspector.

Click in Copy & Customize button and clone the configurations. Now go to Camera and clone again a profile to customize its properties below. This will allow you to add a New Camera Setting Provider.

9

Into New Camera Settings 1, select the Type “Microsoft.MixedReality.Toolkit.Experimental.UnityAR → UnityARCameraSettings”

10

Once a camera is configured, we are going to add a 3D object in our scene (a cube for example) resize it to 0.5 and move our camera in front of it:

11
12

Finally, we are ready to build this solution and generate our APK!