To use Vulkan hardware profiles in your projects:
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.)
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.
Double click the script to open it.
Add the following template code to the script:
using UnityEditor.Android;
using UnityEditor.HardwareProfiles;
public class MyProfileSettings : AndroidHardwareProfiles
{
public override void DefineHardwareProfile(ProfileDatabase database)
{
// ...
}
}
Place code that controls workarounds and device filters in the DefineHardwareProfile method. Refer to Full code example for a full example.
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.
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 BuildA development build includes debug symbols and enables the Profiler. More info
See in Glossary, then check the logcat output.
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:
HasBuggyBackBufferCopyImage workaround and uses OpenGL ES.