Check if prefab is rendered off cam is not working

In my scene I instantiate a prefab in front of the camera. Mean while the camera is slowly moving to the right along the X axis. So after a small amount of time the prefab is off screen.

When that happens I want to delete/clean up that prefab, since it’s not being used anymore. This is how my script that is attached to a prefab looks like:

public class Floor : MonoBehaviour {

	public GameObject floor;

	void Start () {
		Vector3 pos = new Vector3(200f,60f,10f);
		Vector3 realWorldPos = Camera.main.ScreenToWorldPoint(pos);

		Logger.AddLog("cam", "campos: " + realWorldPos.ToString());
                
                // Put floor in the scene
		GameObject firstFloor = (GameObject)Instantiate(floor);
		firstFloor.transform.position = realWorldPos;
	}

	void OnBecameInvisible() {
		Logger.AddLog("bla", "WOOT");
	}
	
	void Update () {
		Logger.AddLog("vis", "visible");
	}
}

The “OnBecameInvisible” method never seems to get called. I also tried to use “renderer.isVisible”. But that gives me the error that “renderer” is not set to an instance of an object.

So what am I doing wrong here?

In the mean time I found out that the “renderer” object isn’t set because I load a “floor” prefab into an empty GameObject. It seems like an empty GameObject doesn’t have a renderer?

But I still haven’t got a solution for my problem yet.

EDIT:
This is weird actually, the prefab has a SpriteRenderer attached to it. So i’d assume I would have access to the “renderer” instance in my code. But for some reason I don’t have that.