How to make Object X spawn when there're no more Objects tagged "XYZ" in scene?

Hey there, I’m trying to come up with a simple script that basically searches for objects in the current scene that are given a certain tag. If those objects still exist, the script continues simply repeats the search…and carries on for eternity until there the tagged objects are all gone. And then the script says “Oh, now I activate my prefab.” Any ideas on how to do this in a very flexible way?

Thanks!

What you are looking for is GameObject.FindGameObjectsWithTag, however, I will note that many people say… “Don’t ever use GameObject.Find…” because it is slow.

The better answer is to have a collection (List) of objects, as objects are added to the scene, add them to the list, when they are removed from the scene remove them from the list. When List.Count is zero, you have no more in the scene.