Search Issue Tracker
By Design
Votes
0
Found in
2022.1.17f1
2022.2.0b8
2023.1.0a10
Issue ID
UUM-15304
Regression
Yes
Changes made by the Script in the UI Document are reset when performing an Undo operation after changing the GameObject with this Script
How to reproduce:
1. Open the user-attached project “BugReport-UI-Toolkit-Undo”
2. Open the “SampleScene” scene
3. Enter the Play Mode
4. Change the position of the “UIDocument” GameObject
5. Perform Undo operation
6. Observe the text in the Play Mode
Expected result: The first line still says “Updated Text”
Actual result: Undo operation also resets the change made by the Script and the first line says “Initial Text”
Reproducible with: 2022.1.0a12, 2022.1.17f1, 2022.2.0b8, 2023.1.0a10
Not reproducible with: 2021.3.10f1, 2022.1.0a11
Couldn’t test with: 2020.3.40f1 (UI Document can't be loaded due to compiler errors)
Reproducible on: Windows 11 Pro
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Search field in UI Builder's Library has no character limit
- Changing the value in UI Builder by dragging increases it by a few thousand points when reaching the borders of the screen
- ARM64 architecture DLL incorrectly copied instead of x64 when building for Windows x64
- Crash on TypeTreeIterator::GetNode when opening a specific folder
- Crash on WriteSerializedAssetsV2 when (re)entering the Play Mode in a specific project when IEnumerator Start() is used
Resolution Note:
This is not something that we can fix. It's how the Undo+Serialization system works in Unity. The system took a snapshot of the UIDocument before entering Play mode. When the script changes the text content (inside UI Toolkit), the system does not know about this change. UI Toolkit elements are not part of the GameObject/MonoBehaviour data. When the user changes the position the GameObject, this action IS recorded. So when you Undo, it simply resets the UIDocument and reloads the UI from UXML, undoing any changes the script made during runtime.