IsEnabled()
Override this method to control whether Unity uses this hardware profile during the Android build.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEditor.Android
- Assembly: UnityEditor.Android.Extensions
public virtual bool IsEnabled()
Returns
Type | Description |
|---|---|
| bool |
Remarks
Unity calls this method during the build process to determine which AndroidHardwareProfiles implementation to use. Return to include this profile in the build, or to skip it. The default implementation returns .
truefalsetrueOverride 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 , Unity throws an exception during the build.
trueReturns if this profile should be used for the build; otherwise, .
truefalseAdditional Resources: AndroidHardwareProfiles.DefineHardwareProfile, Vulkan hardware profiles.
Examples
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); }}