docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Display Utilities

    The Android XR Display Utilities feature enables you to:

    1. Get the supported display refresh rates for the device.
    2. Request a selected display refresh rate.

    Enable Display Utilities

    To enable Android XR Display Utilities in your app:

    1. Go to Project Settings > XR Plug-in Management > OpenXR.
    2. Under OpenXR Feature Groups, select the Android XR feature group.
    3. Enable the Android XR Display Utilities OpenXR feature.

    As a standalone feature of this package, Android XR: Display Utilities solely depends on Android XR Support and does not require that you enable any other feature in the Android XR feature group.

    Code sample

    Once enabled, Android XR Display Utilities adds additional capabilities to Unity's XRDisplaySubsystem using C# extension methods: TryGetSupportedDisplayRefreshRates and TrySetDisplayRefreshRate

    Important

    These extension methods always return false if you did not Enable Display Utilities in XR Plug-in Management.

    The following code sample demonstrates how to use these extension methods:

    // Omitted null checks for brevity. You should check each line for null.
    var displaySubsystem = XRGeneralSettings.Instance
        .Manager
        .activeLoader
        .GetLoadedSubsystem<XRDisplaySubsystem>();
    
    // Get the supported refresh rates.
    // If you will save the refresh rate values for longer than this frame, pass
    // Allocator.Persistent and remember to Dispose the array when you are done with it.
    var getSupportedRefreshRatesStatus = displaySubsystem.TryGetSupportedDisplayRefreshRates(
            Allocator.Temp,
            out var refreshRates);
    if (getSupportedRefreshRatesStatus.IsError())
    {
        Debug.Log($"Failed to get available refresh rates");
        return;
    }
    
    // Request a refresh rate.
    // Returned status will be an error if you request a value that is not in the refreshRates array.
    var setRefreshRateStatus = displaySubsystem.TrySetDisplayRefreshRate(refreshRates[0]);
    if (setRefreshRateStatus.IsError())
    {
        Debug.Log($"Failed to set refresh rate to {refreshRates[0]}");
        return;
    }
    
    
    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)