Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Scripting with Adaptive Performance

Control and monitor device performance at runtime using the Adaptive Performance scripting API.
Read time 1 minuteLast updated 12 days ago

Control and monitor device performance at runtime using the Adaptive Performance scripting API.
After you set up Adaptive Performance, you can use its scripting API to access and control device performance metrics directly from your code. The central point of access is the
IAdaptivePerformance
interface, which Unity automatically creates and manages on a GameObject at runtime.
For a code-free approach using visual graphs, refer to the Adaptive Performance package documentation about visual scripting.

Accessing the instance

To access the instance, use
AdaptivePerformance.Holder.Instance
.
To check if your device supports Adaptive Performance, use the
IAdaptivePerformance.Active
property.

Debug logging

To get detailed information during runtime, enable Logging in the provider settings or via
IDevelopmentSettings.Logging
during runtime or using boot time flags from
IAdaptivePerformanceSettings
:
using UnityEngine;using UnityEngine.AdaptivePerformance;static class AdaptivePerformanceConfig{ // This method runs automatically after assemblies are loaded, before any scene starts. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] static void Setup() { // Retrieve the Adaptive Performance settings. IAdaptivePerformanceSettings settings = AdaptivePerformanceGeneralSettings.Instance.Manager.activeLoader.GetSettings(); // Check if settings were successfully retrieved before modifying. if (settings != null) { // Enable Adaptive Performance logging. settings.logging = true; } }}

Additional resources