docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Display Android Surface content

    You can use XR Composition Layer to efficiently display native, hardware-decoded, or security-sensitive content (such as video) without routing it through Unity’s rendering pipeline. When you are working with Android development, you can render Android Surface content directly to a quad or cylinder composition layers by choosing Android Surface as the source of the Source Texture component.

    Access Android Surface objects with OpenXR

    The Unity OpenXR Plug-in provides composition layers support for Android Surface. To obtain the Android Surface object to use for a layer, you must call the OpenXR GetLayerAndroidSurfaceObject in a script.

    The following example shows how you can use GetLayerAndroidSurfaceObject to access the Android Surface object to use for a layer:

    // Get Android Surface Object
    IntPtr surface = IntPtr.Zero;
    surface = OpenXRLayerUtility.GetLayerAndroidSurfaceObject(layer.GetInstanceID());
    

    You can access a sample using Android Surface from the Package Manager, as outlined in the following instructions:

    1. Open the Package Manager (menu: Window > Package Manager)
    2. Select the XR Composition Layers package in the list of packages in your project.
    3. Towards the bottom of the window, select the Samples tab.
    4. Click Import next to the Sample External Android Surface Project item.

    Additional resources

    • Android Surface (Android developer documentation)
    • XR_KHR_android_surface_swapchain (Khronos)
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)