Unity Issue Tracker - UI Builder button EventListeners stop working when the UI Document gets disabled and re-enabled in Play Mode
Closed
UUM-61551
UI Builder button EventListeners stop working when the UI Document gets disabled and re-enabled in Play Mode
Unity: UI Toolkit Framework
As Designed
2023.3.X
2023.2.X
2022.3.X
2021.3.X
Everything here is working as intended. Elements are regenerated when UIDocument gets disabled and re-enabled. Callbacks registered during the Start method refer to elements that no longer exist, hence why they aren't invoked anymore.
How to reproduce:
1. Open the “UIBuild.zip“ project
2. Open the “SampleScene”
3. Enter the Play Mode
4. Click on the Button in the Game View (to see that the button click event is registered)
6. In the Hierarchy select the "GameObject"
7. Disable and re-enable the UI Document Component
8. Click the Button again
9. Observe the Console window
Expected results: The Button click event is being listened to and displays “I am working“ in the Console after clicking it
Actual results: The Button click event is not being listened to and does not display “I am working“ in the Console after clicking it