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
- Type: Class
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Inherits from: BindableElement
- Implements: IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IBindable, INotifyValueChanged<T>, IMixedValueSupport
public abstract class BaseField<TValueType> : BindableElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IBindable, INotifyValueChanged<TValueType>, IMixedValueSupport
Static Fields
Value | Description |
|---|---|
| alignedFieldUssClassName | USS class name of elements that are aligned in a inspector element |
| inputUssClassName | USS class name of input elements in elements of this type. |
| labelDraggerVariantUssClassName | USS class name of labels in elements of this type, when there is a dragger attached on them. |
| labelUssClassName | USS class name of labels in elements of this type. |
| mixedValueLabelUssClassName | USS class name of elements that show mixed values |
| noLabelVariantUssClassName | USS class name of elements of this type, when there is no label. |
| ussClassName | USS 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 |
|---|---|
| label | The 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. |
| labelElement | This is the Label object that appears beside the input for the field. |
| mixedValueLabel | Read-only label used to give the appearance of editing multiple different values. |
| rawValue | The value of the element. |
| showMixedValue | When set to true, gives the field the appearance of editing multiple different values. |
| value | The value associated with the field. |
Methods
Method | Description |
|---|---|
| SetValueWithoutNotify | Allow to set a value without being notified of the change, if any. |
| UpdateMixedValueContent | Update the field's visual content depending on showMixedValue. |