Search Issue Tracker

By Design

Votes

0

Found in

2019.4

2020.3

2020.3.18f1

2021.3

2022.1

2022.2

Issue ID

1418497

Regression

No

"This Object contains SerializeReference types which are missing." warning appears when renaming the class or namespace

Serialization

-

Reproduction steps:
1. Open the attached "SerializeReference_1209838.zip" project
2. Open the "SampleScene" Scene
3. Go to Hierarchy > Test > Reference and see that the value of the "Value" variable is "2"
4. Change the name of the "TestBehaviour" class or "MyNS" namespace in "SerializeReferenceTest.cs" and "TestBehaviour.cs" scripts
5. Go to Hierarchy > Test > Reference

Expected result: The value of the "Value" variable is "2"
Actual result: The value of the "Value" variable is "0" or "This Object contains SerializeReference types which are missing." warning appears, and the "Reference" field is not displayed

Reproducible with: 2019.4.37f1, 2020.3.33f1, 2021.3.0f1, 2022.1.0b14, 2022.2.0a10

Notes:
- If you open the "Test.prefab" asset after the 4th step, you will see that the reference is laid out as (renamed class or namespace are not updated):
references:
version: 1
00000000:
type: {class: TestBehaviour, ns: MyNS, asm: Assembly-CSharp}
data:
Value: 2
- The warning message appears in 2021.2.0a12 and above

  1. Resolution Note (2022.2.X):

    When using [SerializeReference], class rename are not handled automatically. One way around the issue is to use

    UnityEngine.Scripting.APIUpdating.MovedFromAttribute

    More specifically, using the provided project, you can rename the behavior and successfully load the data using [MovedFrom]

    [MovedFrom(false, null, null, "TestBehaviour")]
    [Serializable]
    public class TestBehaviour1
    ...

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.