ValidateInputΒΆ

The most powerful ValidatorAttribute.

Note

If you want to use it on fields that are nested inside serialized structs or classes you need to use the AllowNesting attribute.

public class NaughtyComponent : MonoBehaviour
{
    [ValidateInput("IsNotNull")]
    public Transform myTransform;

    [ValidateInput("IsGreaterThanZero", "myInteger must be greater than zero")]
    public int myInt;

    private bool IsNotNull(Transform tr)
    {
        return tr != null;
    }

    private bool IsGreaterThanZero(int value)
    {
        return value > 0;
    }
}
../../_images/ValidateInput_Inspector.png