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#.
@LouisIngenthron @peterdrake the reason for this is that Monobehaviours live in the C# layer AND in the C++ layer of Unity. when you destroy a MB or set it to null the C++ layer gets removed from memory right away while the C# layer has to wait for Garbage Collection. In theory you can have MBs which are null in the C++ world but not in the C# world. Thats why its tricky to do null checks on MBs.
@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..."
@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
@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...