unity if outside screen code example Example: how to detect when a gameobject leaves the screen void OnBecameInvisible() { Destroy(gameObject); }