Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

AndroidHardwareProfiles.IsEnabled

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool IsEnabled();

Description

Override this method to control whether Unity uses this hardware profile during the Android build.

Unity calls this method during the build process to determine which AndroidHardwareProfiles implementation to use. Return true to include this profile in the build, or false to skip it. The default implementation returns true.

Override this method to conditionally enable a profile based on build settings, target platform, or other criteria. This is useful when you maintain multiple profile implementations and want to switch between them without removing code.

Note: Only one AndroidHardwareProfiles implementation can be enabled at a time. If multiple implementations return true, Unity throws an exception during the build.

Returns true if this profile should be used for the build; otherwise, false.

Additional resources: AndroidHardwareProfiles.DefineHardwareProfile, Vulkan hardware profiles.

using UnityEditor;
using UnityEditor.Android;
using UnityEditor.HardwareProfiles;

public class PrimaryHardwareProfile : AndroidHardwareProfiles { // Enable profile for production build public override bool IsEnabled() => EditorUserBuildSettings.development == false; public override void DefineHardwareProfile(ProfileDatabase database) { // Configure the default filter for all devices var defaultFilter = database.GetDefaultFilter(); defaultFilter.SetGraphicsAPI(GraphicsAPI.UseVulkan); } }

public class AditionalHardwareProfile : AndroidHardwareProfiles { // Enable profile for development build public override bool IsEnabled() => EditorUserBuildSettings.development == true; public override void DefineHardwareProfile(ProfileDatabase database) { // Configure the default filter for all devices var defaultFilter = database.GetDefaultFilter(); defaultFilter.SetGraphicsAPI(GraphicsAPI.UseOpenGles); } }