Validation
This asset comes with a basic validation system. By default, you will see asset configuration warnings and errors in any of the provided inspectors.
Re-using Built-in Validation Logic
When building custom components using distance fields within this asset's conventions,
you can use the fields and methods of the Distance
If you want to draw their results in your own inspectors, you can implement
IValidation
Integrating With Other Validation Systems
If you use a centralized project validation tool such as Odin Validator or an in-house solution, you are able to extract the provided validations and adapt it to your system:
UnityEngine.Object[] thingsToValidate = UnityEditor.Selection.objects; // Or whatever else you need to validate
var editor = UnityEditor.Editor.CreateEditor(thingsToValidate);
if (editor is not Kroltan.Keen.Editor.Validations.IValidationSource validationSource) {
return;
}
// You can safely cache this value as long as the objects still exist.
var validator = new Kroltan.Keen.Editor.Validations.Validator(validationSource);
foreach (Kroltan.Keen.Editor.Validations.ValidationResult result in validator.Validate()) {
if (result.Type == UnityEditor.MessageType.None) {
continue; // Everything is fine for this validation.
}
// Here you can access the Type and Description of each result and use it in your system.
// Some results implement IFixableResult, which also offer a function you can call to fix the issue.
}
Due to the diversity of validation solutions, no pre-built integrations are included.