IgnoreValidationScope<TValueType> A scope that re-enables validation when disposed.
Disables BaseField<T0>.onValidateValue until the returned scope is disposed.
Scope this method with a using statement and use it with the
BaseField<T0>.value setter or BaseField<T0>.SetValueWithoutNotify to assign a value that bypasses validation.
Only BaseField<T0>.value results in a ChangeEvent<T0>.
The scope can be nested safely.
The following example sets a value that skips the field's validation:
using UnityEngine; using UnityEngine.UIElements;
namespace MyNamespace { public class BaseFieldIgnoreValidationExample { // The field clamps its value to a maximum. IgnoreValidation sets a value that skips the clamp. public IntegerField CreateField() { var field = new IntegerField("Value"); const int max = 100;
field.onValidateValue += v => Mathf.Min(v, max);
// Set a value above the maximum without clamping it. using (field.IgnoreValidation()) field.value = 500;
return field; } } }