Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


IgnoreValidation()

Disables _onValidateValue until the returned scope is disposed.
Read time 1 minuteLast updated 12 days ago

Definition

public BaseField<TValueType>.IgnoreValidationScope IgnoreValidation()

Returns

Type

Description

IgnoreValidationScopeA scope that re-enables validation when disposed.

Remarks

Scope this method with a
using
statement and use it with the _value setter or BaseField<TValueType>.SetValueWithoutNotify to assign a value that bypasses validation. Only _value results in a ChangeEvent<T>. The scope can be nested safely.
The following example sets a value that skips the field's validation:

Examples

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; } }}