Validators
Required
Displays an error helpbox above the variable if it's empty.
Supported property types
String
Object Reference
Exposed Reference
Managed Reference
Parameters
LogError
Code Example
using UltimateAttributesPack;
public class RequiredExample : MonoBehaviour
{
// Required attribute displays an helpbox in inspector if the variable is null
[Required]
public GameObject exampleObject;
// You can also set the param to true to log an error in the console if the variable is null
[Required(true)]
public GameObject secondExampleObject;
}
MinValue
Clamps the variable to a minimum value.
Supported property types
Float
Int
Parameters
MinValue
Code Example
using UltimateAttributesPack;
public class MinValueExample : MonoBehaviour
{
// MinValue attribute clamp the variable to a minimum
[MinValue(0)]
public int intValue;
// It also works with floats
[MinValue(2.5f)]
public float floatValue = 2.5f;
}
MaxValue
Clamps the variable to a maximum value.
Supported property types
Float
Int
Parameters
MaxValue
Code Example
using UltimateAttributesPack;
public class MaxValueExample : MonoBehaviour
{
// MaxValue attribute clamp the variable to a maximum
[MaxValue(5)]
public int intValue;
// It also works with floats
[MaxValue(2.5f)]
public float floatValue;
}
Last updated