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 7 minutesLast updated 2 days ago

Definition

public abstract class BaseField<TValueType> : BindableElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IBindable, INotifyValueChanged<TValueType>, IMixedValueSupport

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.

Properties

Property

Description

labelThe string representing the label that will appear beside the field. If the string is empty, the label element is removed from the hierarchy. If the string is not empty, the label element is added to the hierarchy.
labelElementThis is the Label object that appears beside the input for the field.
mixedValueLabelRead-only label used to give the appearance of editing multiple different values.
rawValueThe value of the element.
showMixedValueWhen set to true, gives the field the appearance of editing multiple different values.
valueThe value associated with the field.

Methods

Method

Description

SetValueWithoutNotifyAllow to set a value without being notified of the change, if any.
UpdateMixedValueContentUpdate the field's visual content depending on showMixedValue.

Inheritance

Inherited Members