Search Issue Tracker
By Design
Votes
0
Found in
2020.3.7f1
2021.1
2021.1.10f1
2021.2
2022.1
Issue ID
1344426
Regression
Yes
Assembly Definition Scriptable Objects loses serialized values when assets are renamed during Play Mode
Reproduction steps:
1. Open the attached project ("ReproBugRename.zip")
2. Open the "SampleScene" scene: Assets > Scenes
3. Enter the Play mode
4. Observe the created assets in the "Assets" folder
5. Left-click on the Game window to modify the values of the created assets
6. Left-click again, to rename the created assets
Expected result: Once the Assembly Definition Scriptable Object is renamed using AssetDatabase.RenameAsset(), the modified values are not changed
Actual result: When the Assembly Definition Scriptable Object is renamed using AssetDatabase.RenameAsset(), the values are changed back to default
Reproducible with: 2020.3.7f1, 2020.3.14f1, 2021.1.14f1, 2021.2.0b3, 2022.1.0a1
Not reproducible with: 2018.4.36f1, 2019.4.29f1, 2020.3.6f1
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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
Resolution Note:
This change in behaviour is by design. We recently made sure that moving/renaming assets correctly updated the main object name to match the filename. This meant that renamed assets effectively become new assets at some level, and in-memory/unsaved changes are carried over by saving the dirty asset data into the 'new' asset.
When changing fields on a ScriptableObject, the object is not automatically dirtied, and these changes can be lost. The solution is to mark the object dirty using EditorUtility.SetDirty() when modifying fields. That way, the changes will be preserved in the renamed/moved asset.