UnityEngine.Object should not be used with null propagation.
IDE0031 - Null check can be simplified
using UnityEngine;
class Camera : MonoBehaviour
{
public Transform NP()
{
return transform != null ? transform : null;
}
}Under normal circumstances, return transform != null ? transform : null can be simplified to return transform?.transform.
Unity has overridden the == operator for UnityEngine.Object. If you use the == operator to compare a UnityEngine.Object to null, it will return true if the UnityEngine.Object is destroyed, even if the object itself isn't actually null. Null propagation cannot be overridden in this way, and therefore behaves inconsistently with the == operator, because it checks for null in a different way.