Answer the question
In order to leave comments, you need to log in
How to remove all th with the same name from the scene?
How to remove all th with the same name from the scene? It's not clear if they are currently on or not.
Answer the question
In order to leave comments, you need to log in
as mentioned above, it is best to initially make them children of one.
if a certain script is attached to all, then you can search by type - FindObjectsOfType
if you set a unique tag, then you can search by tag - FindGameObjectsWithTag
if none of the above is suitable, then the most expensive way remains - to search by type (as in the second option ) GameObject and check the name of each found object:
foreach (var gameObj in FindObjectsOfType(typeof(GameObject)) as GameObject[])
{
if(gameObj.name == "bar")
{
//Do something...
}
}
The easiest option is to make them children of one, and then just go through the children and delete them
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question