Calling Object.Destroy or Object.DestroyImmediate using a Transform argument is not allowed and will produce an error message at runtime.
using UnityEngine;
class Camera : MonoBehaviour
{
public void Update() {
Destroy(transform);
}
}Destroy the related GameObject instead:
using UnityEngine;
class Camera : MonoBehaviour
{
public void Update() {
Destroy(transform.gameObject);
}
}A code fix is offered for this diagnostic to automatically apply this change.