Bindable data types and fields
Learn how to convert data types between the data source and the UI.
읽는 시간 2분최근 업데이트: 한 달 전
This section describes the data type conversions and fields supported by .
PropertyFieldData type conversions
Most built-in controls in UI Toolkit implement the interface for a specific data type. For example, implements , which means you can bind the control to a property of type . You can bind more data types with the binding system. For example, you can bind a property of type to a .
INotifyValueChangedDoubleFieldINotifyValueChanged<Double>DoubleFielddoubleintDoubleFieldThe following table lists the source and target data types that you can bind:
Source data type | Target data type of |
|---|---|
|
|
|
|
|
|
|
|
|
|
Fields supported by PropertyField
PropertyFieldWhen the Inspector window is populated, if a custom Editor doesn't exist for a type, the binding system calls . This creates a for each on the .
InspectorElement.FillDefaultInspector()PropertyFieldSerializedPropertySerializedObjectEach has a matching control under it, such as an to represent an , or a to represent a . If the property has sub-properties, the has a control. That has the appropriate default controls under each sub-property. If you created a custom for a Property, the visual tree returned from the 's method is used instead.
PropertyFieldIntegerFieldintToggleboolPropertyFieldFoldoutFoldoutPropertyDrawerPropertyDrawerCreatePropertyGUI()When you create a custom UI, don't use a unless you can't find a specific control for it. For example, to create a control in your visual tree and bind it to a , use a rather than a . This makes visual trees more lightweight and operations faster.
PropertyFieldColorColorFieldPropertyFieldThe use of incurs additional overhead because it resolves the concrete field to use after binding. This extra step can affect performance. However, is beneficial for some uses. For example, it supports custom drawers, which you can use to handle specific properties in a personalized way. This eliminates the need to guess the field type for drawing, which can reduce errors.
PropertyFieldPropertyFieldThe following table lists fields supported by and their data type:
PropertyFieldField | Data type |
|---|---|
| Bounds |
| BoundsInt |
| Color |
| AnimationCurve |
| float |
| Gradient |
| Hash128 |
| int |
| int, for the ArraySize |
| unit |
| long |
| UnityEngine.Object |
| Enum |
| Rect |
| RectInt |
| string |
| char |
| bool |
| Vector2 |
| Vector2Int |
| Vector3 |
| Vector3Int |
| Vector4 |