Search Issue Tracker
By Design
Votes
9
Found in
4.3.0f4
Issue ID
583896
Regression
Yes
Mono/Unity does not perform null checks properly
To reproduce:
1. Open the attached project
2. Attach the script to the Main Camera
3. Run the scene
4. Observe the logs in the console
5. Observe the script content
----
Script tries to assign a collider that does not exist to a variable then add it to List<Component> if it's not null. The variable gets added to the list but components[0] is null:
var obj = GetComponent<Collider>(); //Get a component that does not exist
components.AddNotNull(obj); //Add it if it is not null
//Check result
Debug.Log("Number of items: " + components.Count + ".");
Debug.Log("First value: " + components[0] + ".");
Explanation:
http://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
Comments (2)
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
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- The layout system is failing to correctly calculate or apply the height of the Japanese fallback font when the primary English font's metrics are used
JoshPeterson
Sep 16, 2014 12:22
We have determined that although this behavior is odd, it is by design at the moment. Please see the discussion in the forum here for more details:
http://forum.unity3d.com/threads/null-check-inconsistency-c.220649
User1234
Apr 26, 2014 16:44
This issue sounds very much like the cause of an NGUI problem reported at...
http://www.tasharen.com/forum/index.php?topic=7515.0
"NGUITools.FindInParents fails sometimes"