The following is an explanation of how the UI Toolkit binding system works at the implementation level.
When you call the Bind()
method, it synchronizes and tracks the first value asynchronously. This means that the value
property of the fields can’t update immediately. This allows you to set up binding for hierarchies that aren’t yet added to any UI.
The binding system relies upon the serialized data of Unity objects to implement change detection.
After you create a binding between a SerializedObject
and one or more elements, the system polls this object for changes at a regular interval, but not every frame, in two steps:
SerializedObject
in native code to detect any change to serialized bytes. If there are no changes, it stops.Some binding operations might be too long to handle in a single frame. If the binding operations are handled in a single frame, the UI might become unresponsive. To prevent this, these binding operations might happen across several frames. For example, it might take several updates to detect changes, depending on the number of objects polled.