The Kanda SDK provides a Project Validation tool that checks your project settings and helps you resolve configuration issues. It's designed to be flexible, allowing you to easily add custom validation rules.
Accessing the Project Validation
You can access the Project Validation view by going into (menu: Edit > Project Settings > Kanda SDK > Project Validation)
Overview
The Project Validation is implemented through automatically rule discovery based on [ProjectValidationRuleSource] attribute. This attribute is applied to static methods that return a collection of SettingsValidationRule objects.
A SettingsValidationRule consists of:
- Message: A message displayed in the UI to inform the user.
- Check Predicate: A function that checks whether the project setting meets a certain condition.
- Fix Action (optional): A function that fixes the issue when the user clicks the
Fix button.
- BuildTargetGroup (optional): Specifies the platform the rule applies to. By default, this is set to
BuildTargetGroup.Unknown, meaning the rule will be enforced for all build targets.
Custom rule setup
1. Create a validation rule
private static SettingsValidationRule ValidateAndroidBuildTarget()
{
var requiredTarget = AndroidArchitecture.ARM64;
return new SettingsValidationRule
{
BuildTargetGroup = BuildTargetGroup.Android,
Message = "Android builds should target ARM64 architecture.",
CheckPredicate =
() => PlayerSettings.Android.targetArchitectures == requiredTarget,
FixAction =
() => PlayerSettings.Android.targetArchitectures = requiredTarget
};
}
2. Create validation rule source method
[ProjectValidationRuleSource]
public static SettingsValidationRule[] GetValidationRules()
{
return new[] { ValidateAndroidBuildTarget() };
}
By using the Project Validation tool, you can streamline your project configuration process and ensure your settings are correct.