EDIT: That explains everything! - Unity creates managed fake wrappers around your UnityEngine.Objects when you destroy them. This means that if you destroy UEObject, the C # shell may still be non-null. == is implemented in its own way, so if you destroy the check, UEObject == null will return true. This obviously does not work very well with generics.
It literally drives me crazy. I have this method right here:
public static void AssertNotNullAfterAssignment<T>(ref T value, Func<T> get, string msg) where T : class
{
if (value == null)
value = get();
if (value == null)
throw new NullReferenceException(msg);
}
I call it by reference null at the beginning:
AssertNotNullAfterAssignment(ref fovMeshFilter, GetComponent<MeshFilter>, "fovMeshFilter");
What really is crazy is that the check if (value == null)returns false! even if the value is null!
Here is a short video I made showing it.
, / , ( OnEnable), ( , OnEnable )
... , , . Equals ==, .
- , ?
: OnEnable, , :
private void OnEnable()
{
AssertNotNullAfterAssignment(ref fovMeshFilter, GetComponent<MeshFilter>, "fovMeshFilter");
}
uncommented lines, , , - --.
Edit1: ?

Edit2:

Edit3:
, . , , ! ! XD - .Equals ==. @Edin, == System.Object == - .Equals Equals. , , , '==' ?