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
- Undo does not revert anchor preset changes when multiple UI elements are modified at once
- [SW-unity-6-1] The light flickers when “Alpha Blend” Overlap Operation is used
- [SW-unity-6-1] Shader warning in the Inspector when selecting ‘Shader Graphs/ShaderGraph_Water_Unlit’ Shader
- Shader warnings appear when Painting Trees on Terrain using Terrain Sample Assets
- Environment Samples count resets to 2048 when entering a higher number
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.