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
- Visual Studio 2019 with the “Game development with Unity” module
- Unity (v2019.2.17f1) with the following modules:
- Mixed Reality Toolkit 2.2.0 unity packages (you can download them here):
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:
On the next screen select a 3D project, a name and folder to save it:
Now, go to File → Build Settings and switch the platform to Android:
On Player Settings, go to Settings for Android → Other Settings and remove Vulkan from Graphic APIs list.
For the next step, we have to import the MRTK packages:
And apply all default settings on this project:
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
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.
Into New Camera Settings 1, select the Type “Microsoft.MixedReality.Toolkit.Experimental.UnityAR → UnityARCameraSettings”
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:
Finally, we are ready to build this solution and generate our APK!