Search Issue Tracker
By Design
Votes
1
Found in
5.3.4f1
Issue ID
789372
Regression
No
NullReferenceException when selecting game object and the game manager object in the hierarchy is not selected
How to reproduce:
1. Open the attached project "789372Exception.zip"
2. Open and play Example scene
3. Click 3 times on the left object in the game view
4. Notice NullReferenceException
5. Select Game Manager in Hierarchy and repeat steps 2-3
6. There is no exception
The GameManager component has a serializable field. When the GameManager is created at runtime, this field is null. However, if the GameManager GameObject is selected in the editor, the field that was null become instantiated and is no longer null.
Thus, simply selecting GameObjects in the editor can change how the game executes. This is an issue in how we handle serialization.
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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
Resolution Note (2017.2.0f3):
The behavior seen is a consequence of the serialization layer's design decisions: 'ref values' (classes) are treated as 'value types' and the scenario here is that object state differs between if a serialization/deserialization cycles occurred vs if it did not occur, basically: user is assuming that serialization restores objects exactly as it was, which is not true for 'ref types'.
of note: is an up coming version, unity will have support for serializing ref types as references in an 'opt-in' manor, so would not fix this issue out of the box, but would give the user one more path forward.