Fun tidbits from the docs on MonoBehaviour:
"This class doesn't support the null-conditional operator (?.) and the null-coalescing operator (??)."
There is a cryptic note that "There is a checkbox for enabling or disabling MonoBehaviour in the Unity Editor. It disables functions when unticked. If none of these functions are present in the script, the Unity Editor does not display the checkbox. The functions are:
Start()
Update()
FixedUpdate()
LateUpdate()
OnGUI()
OnDisable()
OnEnable()"
It does not say where this checkbox is, nor why you would want to do this.
@peterdrake For the same reasons, it does not support the "is null" / "is not null" syntax in newer versions of C#.
@bernardo_olafson @peterdrake To add to this, if I recall correctly, they'll also "== null" not only when they're actually destroyed, but also when they're queued for destruction (i.e. when you call Destroy() rather than DestroyImmediate()).
But the benefit of all this nonsense is that we can use "== null" as a check of destruction, rather than having to clean up all of our own references to any object we destroy!
@peterdrake @LouisIngenthron Unity documentation is quite poor when it comes to more in depth technical info, indeed. you need to collect info from several sources. yes, this can suck...
@peterdrake @LouisIngenthron @bernardo_olafson
The manual pages (rather than scripting reference) is generally better for high level stuff. Pages like this one: https://docs.unity3d.com/Manual/ExecutionOrder.html
The overriding of the null comparison has been an oddity with many unexpected side effects and has been discussed for many many years. It's definitely a doozy :D
@LouisIngenthron @bernardo_olafson My beef (well, one of my beeves) is that this business isn't documented anywhere that is (to me) obvious. It's just scattered around various conflicting and unclear StackOverflow posts, with endless offramps to things like "is {}".
Unity is like Columbo, always turning around at the end and saying, "Oh, and one more thing..."