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
- [Android] Audio sound is lower in the Player compared to the native music player
- Feet slide and misalign when playing retargeted animations
- IndexOutOfRangeException is thrown in NativePassCompiler when a graphics buffer is used in more than 5 render passes
- "Undo Stack Overflow" error is thrown, and Undo History is deleted when multiselected GameObjects are reparented to their GrandParents
- SearchColumn of type "ObjectReference" does not get refreshed for the custom SearchProvider when lighting generation finishes
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.