Quick answer: Unity UI Toolkit data binding losing references after a script rebuild? Bindings keyed by C# type name - rebuild clears the binding registry, re-call SetBinding on enable.
Bound a label to a SerializedProperty. After a play-test reload, the label is blank and the binding silently dropped.
Re-bind on enable
void OnEnable() { label.SetBinding("value", binding); }Rebuilds clear the registry. The cheapest fix is to re-call SetBinding from OnEnable.
Use the [Binding] attribute
Decorate the binding source with [CreateProperty]. UI Toolkit's source generators emit the binding wiring at compile time so reload preserves it.
Verify in the binding inspector
Selected element > Bindings panel. After reload, the panel shows the live bindings; an empty list means they've been dropped.
“UI Toolkit bindings are a runtime registry. Domain reload clears the registry.”
For complex UIs, generate binding wiring at edit time. The source generators are stable in Unity 2023.2+ and worth the migration.