Search Issue Tracker
Duplicate
Votes
1
Found in
2019.3
2019.3.0f3
2020.1
Issue ID
1206352
Regression
No
Class constructor is not invoked when adding SerializeReference attribute
How to reproduce:
1. Open the attached project "1206352.zip"
2. Open the SampleScene
3. Select the Container script (Assets -> Runtime -> Container)
4. Reimport the script (right-click -> Reimport)
5. Enter Play mode and notice Default value being logged
6. Exit Play mode and uncomment the [SerializeReference] attribute of the Container script
7. Enter Play mode
Expected result: Default value is logged
Actual result: NullReferenceException is thrown
Reproducible with: 2019.3.0f4, 2020.1.0a18
Notes:
Reimporting the script when [SerializeReference] attribute is uncommented will stop the Item class constructor from being invoked.
Creating a new ScriptableObject (right-click -> Create -> Container) will Invoke the constructor.
[SerializeReference] attribute was not available prior to Unity 2019.3, therefore the issue is not reproducible.
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
- Memory leak when a lot of UI elements are spawned and despawned
- Warnings are not logged in the Console window when using external code analyzers
- Errors “TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 288“ appear constantly when Prefab is open
- Crash on PPtr<Shader>::operator or NullException errors spammed in console when calling Dispose() on null GraphicsBuffer with baked Reflection Probes
- “EndRenderPass: Not inside a Renderpass” and other Render Graph errors in the Player when Render Graph is enabled and Overlay UI is used
This is a duplicate of issue #1193322