Unity’s cross-platform mixed reality template for Meta Quest, HoloLens 2 & Magic Leap 2

  • 3 December 2023
  • 3 December 2023
  • 4 min read
Cross-platform Mixed Reality Development for Meta Quest, HoloLens 2 & Magic Leap 2 with Unity tutorial by the Black Whale Studio

Introduction

Hello XR developers! 🚀 Today, we’re embarking on an exciting journey to install and set up Unity’s versatile cross-platform mixed reality template. This template is a game-changer for developers working with Meta Quest, HoloLens 2, and Magic Leap 2. It includes features like plane detection, passthrough, simple interactables, spatial UI, and hand and controller presence. If you’re into this kind of content, consider supporting my work on Patreon or subscribing to the channel. Join our XR Developer Discord community for any questions. Let’s dive in!

Check out this blog post or the setup guide from Unity!

Getting Started with Unity’s Mixed Reality Template

  1. Prerequisites: Ensure you have a Meta Quest device and Unity version 2022.3.11 or later. Download the latest Unity version and include the Android modules for later app testing.
  2. Setting Up the Template: There are two ways to set up the mixed reality template:
    • New Project: Create a new project and download the mixed reality sample. This comes pre-configured with various prefabs and custom scripts.
    • Existing Project: Upgrade your project to Unity 2022.3.11 or later, then add the package “com.Unity.XR.Meta-OpenXR” via the package manager. Note that this method requires manual setup for XR Plugin Management and XR Hands.
  3. Exploring the Template: The template is fully configured with OpenXR, AR-Foundation, XR Hands, and the XR Interaction Toolkit. Check the project settings and XR Plug-in Management to see the configuration.

Configuring and Testing the App

  1. Graphics and Rendering Settings: Unity recommends specific settings for Meta Quest 2 (“performant”) and Meta Quest 3 and Pro (“balanced”). Adjust these in the “Quality” and “Graphics” tabs in your project settings.
  2. Building for Android: Switch to the Android platform to build an APK and test the Mixed Reality app on your device.
  3. Space Setup: Before testing, set up your physical space using your headset’s settings. Accurate room scanning ensures a better experience with AR-Foundation’s plane detection.

Exploring the Sample App

  1. Interactive Features: The sample app includes a wrist-menu for AR mode and scene configuration, plane detection for object placement, and a variety of UI settings.
  2. Unity’s Video Player Prefab: Experience the intuitive video player with ray-cast snapping and interactive play/pause buttons.
  3. Sample Scene Analysis:
    • Environment and Lighting: A simple setup to start with.
    • MR Interaction Setup: Includes the main components for mixed reality interactions.
    • UI GameObject: Contains the coaching UI for initial tutorials.
    • Hand-Menu Setup: Tracks hands and detects palm orientation.
    • Spatial Panel Manipulator: Showcases the new video player with XR Grab Interactable and affordance providers.
  4. Affordance System: A new feature by Unity that enhances interactables with audio and visual feedback.
  5. Object Spawning: Utilizes a custom “Object Spawner” and a “Palm” game-object with a “Contact Spawn Trigger” for spawning objects by touching a plane.

Conclusion

Unity’s cross-platform mixed reality template opens up a world of possibilities for XR development across devices like Meta Quest, HoloLens 2, and Magic Leap 2. With its comprehensive features and easy setup, it’s an invaluable tool for developers looking to create immersive mixed reality experiences. Dive into this template, experiment with its features, and share your thoughts and creations with our community. Happy developing!

Support Black Whale🐋

If you find our content helpful, consider supporting us on Patreon. Your contributions enable us to continue creating free, high-quality educational material 👍.

Thank you for following this tutorial. Stay tuned for more in-depth and insightful content in the realm of XR development! 🌐

Did this article help you out? Consider supporting me on Patreon or simply subscribe to my YouTube channel!

3 replies on “Unity’s cross-platform mixed reality template for Meta Quest, HoloLens 2 & Magic Leap 2”

  • Nick Costello
    19 February 2024 at 14:39

    Just ran across this after fighting with the template for a few days. Thanks for the tutorial. I’ve run these exact steps on multiple quest 3’s and multiple versions of unity and not once have I been able to get plane detection working. I’m going to try and drop back to version 2022.3.11 from 2022. 3.20 as you suggested in the video and give it a try.

    One thing I have noticed is the is that the AR plane manager on the open XR origin is disabled in the template. I’ve tried with it on and off, still can’t get planes to detect and yes I’ve configured the room and added tables.

    The only errors I am getting in Quest Developer Hub are RPC related errors about Shared Anchors which I don’t think the template even utilizes. It’s been one hell of a frustrating experience.

  • Farzaneh Gerami
    25 February 2024 at 10:55

    Thank you for the tutorial. I have a question: Can HoloLens 2 be used if the build setting is configured for Android, or is it necessary to build for UWP instead? Additionally, is it feasible to utilize a Mixed Reality template with HoloLens?

    • 25 February 2024 at 11:06

      You have to install the windows universal platform module and the MRTK from Microsoft following the guide from Microsoft for setting up Unity projects with MRTK and then fixing the warning in the project from the template which only then shows all necessary fixes for the windows universal platform configuration

Leave a Reply

Your email address will not be published. Required fields are marked *