APPS

Getting started with Unity and Android XR



Posted by Luke Hopkins – Developer Relations Engineer

Samsung Galaxy XR is here, powered by Android XR! This blog post is part of our Android XR Spotlight Week, where we provide resources—blog posts, videos, sample code, and more—all designed to help you learn, build, and prepare your apps for Android XR.

There’s never been a better time to get into XR development. Last December, we announced Android XR, Google’s new Android platform built on open standards such as OpenXR and Vulkan, which makes XR development more accessible than it’s ever been.

And when combined with Unity’s existing XR tools, you get a powerful and mature development stack. This makes it possible to create and deploy XR apps that work across multiple devices.


No matter whether you’ve done XR development before or not, we want to help you get started.

This blog will get you up and running with Android XR and Unity development. We’ll focus on the practical steps to configure your environment, understand the package ecosystem, and start building.

By the end of this blog, you’ll have a good understanding of:

  • The package ecosystem

  • Essential setup steps

  • Input methods

  • Privacy and permissions

  • Composition layers

Unity for Android XR development


You might choose Unity for its cross-platform compatibility, allowing you to build once and deploy to Android XR and other XR devices.

When using Unity, you benefit from its mature XR ecosystem and tooling. It already has established packages such as XR Interaction Toolkit, OpenXR plugin, XR composition layers, XR Hands, an extensive asset store full of XR-ready components and templates, and XR simulation and testing tools. And since Unity 6 was released last November, you’ll also benefit from its improved Universal Render Pipeline (URP) performance, better Vulkan graphics support, and enhanced build profiles.

Here are some sample projects to get an idea of what can be done:

Essential setup: your development foundation

Unity 6 requirements and installation

You’ll need Unity 6 to create your app, as earlier versions don’t support Android XR. Install Unity Hub first, then Unity 6 with the Android Build Support module, following these steps.

Android XR build profiles: simplifying configuration

Unity build profiles are project assets that store your platform-specific settings and configurations. So instead of needing to manually set up 15-20 different settings across multiple menus, you can use a build profile to do this automatically.
You can create your own build profiles, but for now we recommend using the dedicated Android XR build profile we created.

You can select your build profile by selecting File > Build Profile from your Unity project. For full instructions, see the Develop for Android XR workflow page.

If you make any changes of your own, you can then create a new build profile to share with your team. This way you ensure consistent build experience across the board.

After these steps you can build and run your APK for Android XR devices.

Graphics API: why Vulkan matters

Once you have your Unity project set up with an Android XR build profile, we first recommend making sure you have Vulkan set as your graphics API. Android XR is built as a Vulkan-first platform. In March 2025, Google announced that Vulkan is now the official graphics API for Android. It’s a modern, low-level graphics API that helps developers maximize the performance of modern GPUs and unlocks advanced features like ray-tracing and multithreading for realistic and immersive gaming visuals.

These standards provide the best compatibility for your existing applications and ease the issues and costs of porting. And it makes it possible to enable advanced Android XR features such as URP Application Space Warp and foveated rendering

Unity 6 handles Vulkan automatically, so when you use the Android XR build profile, Unity will configure Vulkan as your graphics API. This ensures you get access to all the advanced Android XR features without any manual configuration.

You can verify your graphics API settings by going to ‘Edit’ >’ Project Settings’ > ‘Player’ > ‘Android tab’ > ‘Other settings’ > ‘Graphics APIs’.

Understanding the package ecosystem

There are two different packages you can use for Android XR in Unity. One is by using the Android XR Extensions for Unity, and the other is using the Unity OpenXR: Android XR package.

These may sound like the same thing, but bear with me.

The Unity OpenXR: Android XR package is the official Unity package for Android XR support. It provides the majority of Android XR features, made available through OpenXR standards. It also enables AR Foundation integration for mixed reality features. The primary benefit of using the Unity OpenXR: Android XR package is that it offers a unified API for supporting XR devices.

Whereas the Android XR Extensions for Unity is Google’s XR package, designed specifically for developing for Android XR devices. It supplements the Unity OpenXR package with additional features such as environment blend modes, scene meshing, image tracking, and body tracking. The tradeoff is that you can only develop for Android XR devices.
Which one you choose will depend on your specific needs, but we generally recommend going with the Unity OpenXR: Android XR, as it gives you far more flexibility for the devices your app will be compatible with, and then based on your application requirements you can then add Android XR Extensions for Unity.

How to install packages

To add a new package, with your project open in Unity, select ‘Window’ > ‘Package Management’ > ‘Package Manager’.

From here you can install these packages from the ‘Unity Registry’ tab:

You can install the Android XR for unity package via Github by selecting the ➕ icon, selecting ‘Install package from git URL’, then entering ‘https://github.com/android/android-xr-unity-package.git’

Required OpenXR features

Now you have the packages you need installed, let’s enable some core features in order to get our project working.

You can enable OpenXR setting for Android: ‘Edit’ -> ‘Project Settings’ -> ‘XR Plugin Management’ -> Click the Android and enable OpenXR


Next we need to enable support for: ‘Android XR support’, we will cover other OpenXR features as we need them. For now we just need Android XR support to be enabled.

Input

Android XR supports input for Hands, Voice, Eye tracking, Keyboard and Controllers. We recommend installing the XR Interaction Toolkit and XR Hands as these contain the best prefabs for getting started. By using these prefabs, you’ll have everything you need to support Hands and Controllers in your app.

You can edit these settings by going to ‘Edit’ > ‘Project Settings’ > XR Plug-in Management’ > ‘OpenXR’

We’d also recommend Unity’s prefab, XR Origin, that represents the user’s position and orientation in XR space. This contains the camera rig and tracking components needed to render your XR experience from the correct viewpoint.

The simplest way to add this prefab is to import it from the hands integration demo we imported earlier which can be found here ‘Hands Integration Toolkit’ > ’Hand Interaction’ > ’Prefabs’ > ’XR Origin’

I recommend using this Prefab over the ‘XR Origin’ option in your game objects as it uses the XR Input Modality Manager which automatically switches between users hands and controllers. This will give you the best success for switching between hands and controllers.

Privacy and permissions: building user trust

Whatever you build, you’ll need to capture runtime permissions from the users. That’s because scene understanding, eye tracking, face tracking and hand tracking provide access to data that may be more sensitive to the user.

These capabilities provide deeper personal information than traditional desktop or mobile apps, so the runtime permissions ensure your users have full control over what data they choose to share. So, to keep with Android’s security and privacy policies, Android XR has permissions for each of these features.

For example, if you use the XR Hands package for custom hand gestures, you will need to request the hand tracking permission (see below) as this package needs to track a lot of information about the user’s hands. This includes things like tracking hand joint poses and angular and linear velocities;

Note: For a full list of extensions that require permissions, check out information on the XR developer website.

const string k_Permission = “android.permission.HAND_TRACKING”;

#if UNITY_ANDROID

void Start()

{

    if (!Permission.HasUserAuthorizedPermission(k_Permission))

    {

        var callbacks = new PermissionCallbacks();

        callbacks.PermissionDenied += OnPermissionDenied;

        callbacks.PermissionGranted += OnPermissionGranted;

        Permission.RequestUserPermission(k_Permission, callbacks);

    }

}

void OnPermissionDenied(string permission)

{

    // handle denied permission

}

void OnPermissionGranted(string permission)

{

    // handle granted permission

}

#endif // UNITY_ANDROID

Enhancing visual quality with composition layers

A Composition Layer is the recommended way to render UI elements. They make it possible to display elements at a much higher quality compared to Unity’s standard rendering pipeline as everything is directly rendered to the platform’s compositor.

For example, if you’re displaying text, the standard Unity rendering is more likely to have blurry text, soft edges, and visual artifacts. Whereas with composition layers, the text will be clearer, the outlines will be sharper, and the experience will be better overall.


As well as text, it also renders video, images, and UI elements at a much higher quality. It does this by utilising native support for the runtime’s compositor layers.

To turn on Composition Layers, open Package Manager, select ‘Unity Register’, then install ‘XR Composition Layers’.

Build and Run

Now that you have your OpenXR packages installed and features enabled, a prefab setup for hand and head movement you can now build your scene and deploy directly to your headset for testing.

What’s next: expanding your skills

Now that you’ve got your Android XR development environment set up and understand the key concepts, here are the next steps to continue your XR development journey:

Essential resources for continued learning:


Sample projects to explore:



Source link

MarylandDigitalNews.com