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

Asset - Database

-

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

  1. 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.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.