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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
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.