Search Issue Tracker
Fixed
Fixed in 2021.3.18f1, 2022.2.2f1, 2023.1.0a22
Votes
8
Found in
2022.2.0b3
Issue ID
UUM-6733
Regression
No
MovedFrom attribute doesn't work on prefab overrides
Quick summary: When a SerializeReference object creation is recorded in a PropertyModification, and that type is missing, then the error handling is poor, the MovedFrom attribute is not respected, and the data can be lost.
*Customer's repro steps:*
Have a monobehaviour, ThingContainer, under asmdef A
- Have that mono contains a list of Things, with a SerializeReference attribute
- Decide to move all Things classes under a new asmdef, B
- This will break the SerializeReference lists on all objects created before the change, and can be fixed using the very undocumented MovedFrom attribute
- This will work if in an old scene contains a regular ThingContainer - not as a prefab, it will work an old scene contains ThingContainers in prefabs, without any override on the list
- BUT it doesn't work for all instances of prefabs in scenes that have overrides on the list. In that case you'll get the usual "A field decorated with [SerializeReference] references an unknown managed type!" as seemingly the MovedFrom attribute is ignored.
This is pretty bad as it basically prevents any refactoring / movement of classes used with SerializeReference.
I've tested and reproduced this from 2019.4.37f1 to 2021.3.1f1.
*Internally created repro steps: *
(created 2021.3.6f1, but expect it will reproduce in a similar way on 2021.3 and later)
* Open the [^UUM-6733-MovedFrom.zip]project
* Open the scene and confirm there is a prefab instance with overrides on the ThingContainer component, also a regular game object with same content
!image-2022-06-28-12-29-42-158.png!
* Close the scene
* Open the project in visual studio and change the "#if true" line to "#if false". This switches to a renamed version of the referenced class, with MovedFrom attribute.
* Go back to Unity and let it do a domain reload, then reload the scene
* Results: Asserts are hit. And the the prefab instance has lost its elements
!image-2022-06-28-12-37-14-381.png!
The regular game object has the expected behaviour (it hasn't lost its list):
!image-2022-06-28-12-38-10-573.png!
Expected result: The prefab instance shows the 3 elements of the array, just like the regular game object.
Note: The attached project includes code and comments showing how i setup the scene in the first place. We can adapt this into a self-contained automated test (or perhaps add the original scene file to source control).
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
- Graphics.DrawProcedural doesn't work like in DX11 when used with DX12
- [Quest 2] Running Entities Graphics/BatchRendererGroup under Vulkan results in a frame rate drop compared to OpenGLES 3 and causes Tile Binning to cost more
- Filters dropdown: Window doesn't rescale on items collapse
- Sprite Preview is broken when the Sprite is too tall or too wide
- Objects are invisible in Scene view when using Wireframe Shading Mode
Resolution Note (fix version 2023.1.0a22):
Fix issue where de-serializing Prefab containing a SerializeReference which has been refactored not handles MovedFrom. Improved AssetDatabase script type dependency so that if a missing SerializeReference instance type, re-appears importers depending on it will be triggered.