The .?
operator ignores the overridden ==
operator of UnityEngine.Object.
It is basically a x is null
check under the hood.
assuming obj is a UnityEngine.Object
UnityEngine obj;
// declare and set null
obj = null;
Debug.Log(obj == null); // true (slow)
Debug.Log(obj == true); // false (faster)
Debug.Log(obj is null); // true (fastest)
// intialize
obj = new UnityEngine.Object();
Debug.Log(obj == null); // false (slow)
Debug.Log(obj == true); // true (faster)
Debug.Log(obj is true); // true (fastest) - just checks if the C# object is not null (ignores overriden == operator)
// destroy
UnityEngine.Destroy(obj);
Debug.Log(obj == null); // true (slow)
Debug.Log(obj == true); // false (faster)
Debug.Log(obj is null); // might be true (not deterministic) C#7 feature btw