Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


BaseField<TValueType>

Abstract base class for controls. A BaseField is a base class for field elements like TextField and IntegerField. To align a BaseField element automatically with other fields in an Inspector window, use the.unity-base-field__aligned USS class. This style class is designed for use with Inspector elements like PropertyField, which has the style class by default. However, if you manually add a child BaseField element to a PropertyField, you must add the style class manually. When the style class is present, the field automatically calculates the label width to align with other fields in the Inspector window. If there are IMGUI fields present, UI Toolkit fields are aligned with them for consistency and compatibility.
Read time 10 minutesLast updated 2 days ago

Definition

[UxmlElement]public abstract class BaseField<TValueType> : AbstractBaseField, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle, IBindable, IMixedValueSupport, INotifyValueChanged<TValueType>

Static Fields

Value

Description

alignedFieldUssClassNameUSS class name of elements that are aligned in a inspector element
inputUssClassNameUSS class name of input elements in elements of this type.
labelDraggerVariantUssClassNameUSS class name of labels in elements of this type, when there is a dragger attached on them.
labelUssClassNameUSS class name of labels in elements of this type.
mixedValueLabelUssClassNameUSS class name of elements that show mixed values
noLabelVariantUssClassNameUSS class name of elements of this type, when there is no label.
ussClassNameUSS class name of elements of this type.

Constructors

Constructor

Description

BaseField`1(System.String,UnityEngine.UIElements.VisualElement)Initializes and returns an instance of BaseField<TValueType>.

Properties

Property

Description

rawValueThe value of the element.
valueThe value associated with the field.

Methods

Method

Description

IgnoreValidationDisables _onValidateValue until the returned scope is disposed.
SetValueWithoutNotifyAllow to set a value without being notified of the change, if any.

Events

Member

Description

onValidateValueAn event raised to validate or adjust the field's value before committing it.

Structs

Struct

Description

BaseField<TValueType>.IgnoreValidationScopeA scope, returned by BaseField<TValueType>.IgnoreValidation(), that disables _onValidateValue until it is disposed.

Delegates

Delegate

Description

BaseField<TValueType>.ValidateValueHandlerRepresents a method that validates or adjusts a field's value before committing it.

Inheritance

Inherited Members