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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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.