Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Enable Vulkan hardware profiles in your project

Follow these steps to set up a Vulkan hardware profiles script.
Read time 2 minutesLast updated 11 days ago

To use Vulkan hardware profiles in your projects:
  1. In Unity, create an
    Editor
    folder in your
    Assets
    folder if one doesn’t exist already. (Right click in the
    Assets
    folder, select Create > Folder, and rename the folder to
    Editor
    .)
  2. In the
    Editor
    folder, right click, select Create > Scripting > Empty C# Script, and name the script
    MyProfileSettings.cs
    . This creates a new script in your folder.
  3. Double click the script to open it.
  4. Add the following template code to the script:
    using UnityEditor.Android;using UnityEditor.HardwareProfiles;public class MyProfileSettings : AndroidHardwareProfiles{ public override void DefineHardwareProfile(ProfileDatabase database) { // ... }}
  5. Place code that controls workarounds and device filters in the
    DefineHardwareProfile
    method. Refer to Full code example for a full example.
  6. Either build or export your project. For information about how Unity handles hardware profiles when you select these options, refer to Build or export your project with hardware profiles.
  7. Once your project builds, check that your application runs as expected.
Note
Unity validates workaround names at application startup. To view validation errors, build and run your application as a
Development Build

?

, then check the logcat output.

Full code example

The following code is an example of how to create a filter for a device and then change the device's workarounds:
using UnityEditor.Android;using UnityEditor.HardwareProfiles;public class MyProfileSettings : AndroidHardwareProfiles{ public override void DefineHardwareProfile(ProfileDatabase database) { var myDefault = database.GetDefaultFilter(); // Disable every workaround on default profile. myDefault.DisableAllWorkarounds(); // o1s is the codename of the S21 var thatOneSamsung = database.CreateFilter( "", "", "Samsung", "o1s"); thatOneSamsung.SetWorkaround("HasBuggyBackBufferCopyImage", State.Disabled); thatOneSamsung.SetGraphicsAPI(GraphicsAPI.UseOpenGles); }}
When you build your project with this example, check that:
  • The mobile device disables all Vulkan workarounds.
  • Samsung S21 doesn't use the
    HasBuggyBackBufferCopyImage
    workaround and uses OpenGL ES.

Additional resources