Skip to content

Property Validator

  1. Create new folder and name it Editor.
  2. Inside Editor folder create new class, ExampleValidator.cs

    public class ExampleValidator
    {
    
    }
    

  3. Inherit from PropertyValidator class.

    public class ExampleValidator : PropertyValidator
    {
    
    }
    

  4. Implement abstract method Validate.

    public class ExampleValidator : PropertyValidator
    {
        public override void Validate(SerializedProperty property)
        {
            // Property validation here...
        }
    }
    

  5. Add ValidatorTarget attribute and set ExampleAttribute as target to this view.

    [ValidatorTarget(typeof(ExampleAttribute))]
    public class ExampleValidator : PropertyValidator
    {
        public override void Validate(SerializedProperty property)
        {
            // Property validation here...
        }
    }