How to check if there are 10 objects with the same tag in the scene

Is there a way to check if there are for example 10 objects in the scene with the same tag (“Answer”).

I want to do something if there are 10 objects in the scene with the same tag. It should look a bit like this, I think.

if([10]ObjectsWithTag == Answer){Debug.Log("10ObjectsWithSameTag");}

So my question, how do you check if there are 10 objects with the same tag in your scene.

You can use GameObject.FindObjectsWithTag(string tag), but be carefull not to user it inside a frequently called function since it is a performance killer.

int taggedObjectsCount = GameObject.FindObjectsWithTag("Answer").Length;

if (taggedObjectsCount >= 10)
{
    Debug.Log (taggedObjectsCount + " objects with that Answer found."); 
}

Check out this documentation:

In your case you want to do something like:

listWithSameTag = GameObject.FindGameObjectsWithTag("Answer");
if (listWithSameTag.size() == 10) {
    // There is 10 objects with the same tag!
}