Skip to content

IPropertyValidatorReceiver

Interface to receive callbacks when initializing Apex attributes.

The callback interface only works with Apex attributes: View, Painter, Validator.


Description

Use this interface to restrict how your attribute works with specific properties.

Implement IPropertyValidatorReceiver interface and implement IsValidProperty method.

bool IsValidProperty(SerializedProperty property, GUIContent label)
{
    return true/false;
}
Parameter Description
property Serialized property of current attribute.
label Label of serialized property.

Return true if this property valid the using with this attribute.

If return false, this attribute will be ignored.


Example

For example you created an attribute for working with arrays and you want to be sure that this attribute will only work with arrays, and for other types it will be ignored.

[ViewTarget(typeof(ArrayAttribute))]
public class ArrayView : PropertyView, IPropertyValidatorReceiver
{
    // Array view code..

    public bool IsValidProperty(SerializedProperty property, GUIContent label)
    {
        return property.isArray;
    }
}