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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
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.