Search Issue Tracker
C# 6 null conditional access operator (?.) throws MissingComponentException instead of recognizing as null
1. Open attached Unity project "CSharpBug.zip"
2. Open "TestScene" scene
3. Inspect both "ThrowsException" and "Safe" GameObjects and scripts attached to them
4. Go into play mode
Expected result: Both scripts should yield the same results (print the success message)
Actual result: In Throws Exception script, there is a ?. operator which works as a check whether the object is null or not. Instead of ignoring the whole line of script, as meshfilter in this case is null, MissingComponentException is thrown.
Reproduced on: 2017.1.0p3, 2017.2.0b7, 2017.3.0a4
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Assertion triggered when using Compile and show code button in Shader inspector
- Wrong elements are selected when holding shift and selecting Game Objects in the Scene Hierarchy
- "Unknown managed type referenced" error is thrown on Play Mode enter with Profiler recording
- CapsuleCast won't detect a hit with a mesh, if the direction happens to be along a face
- ShaderUtil.GetShaderData(shader).SubshaderCount does not count unsupported subshader