Search Issue Tracker
Fixed in 2020.2.X
Fixed in 2019.4.X, 2020.1.X
Votes
5
Found in
2019.3
2020.1
Issue ID
1183547
Regression
No
[Serialization] Empty class instances are not deserialized and become null.
To reproduce:
1. Open LocalizationTests project from the link provided in the edit
2. Delete the "Localization Settings.asset" and create a new one with "Create/Localization/Localization Settings"
3. Notice that the list of Sources is full of class names
4. Save project and quit Unity
5. Open the project again and select the localization settings asset, observe the empty classes
Expected result: Empty classes are not null
Actual result: Empty classes are null
Reproducible in: 2017.4.35f1, 2018.4.14f1, 2019.2.16f1, 2019.3.0f2, 2020.1.0a15
Notes:
1. If the asset file is opened with a text editor it can be seen that it is correctly saved, the classes have just not been deserialized
2. As a workaround add a simple dummy field in the managed reference/class
Comments (1)
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
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- The layout system is failing to correctly calculate or apply the height of the Japanese fallback font when the primary English font's metrics are used
Catsoft-Works
Mar 10, 2020 11:40
Yup, It's a bit odd having to add a dummy field in order to correctly deserialize the class instance. So having something like:
public interface IAnimal
{ }
[System.Serializable]
public class Cat : IAnimal
{ }
[SerializeReference]
public IAnimal animal = new Cat();
Results in a null after restarting Unity. However, if you change the Cat class definition for:
[System.Serializable]
public class Cat : IAnimal
{
public int dummy = 1;
}
It works fine. Hope this helps narrow down the problem.