void OnValidate() { theValue = Mathf.Clamp(theValue, 0, float.MaxValue); // or int.MaxValue, if you need to use an int but can't use uint. }