How do I find all game object possessing the same name? (120337)

“GameObject.Find()” only picks one

Please do not recommend Tags to me, that’s not what I need here

e.g.

Say I have 200 obj, 100 of them are named Blue and the other 100 are named Red

I want to find all the obj in my scene named Blue and Tag them Blue, find all the obj named Red and Tag them Red

Obviously I want to do all this in code instead of individually finding and Tagging all 200 objects myself in a scene where some of the objects are children of other objects

Ugh. This is what tags are for. Names are not optimised for this. Set the tag instead of the name. Note: If you are doing this in the editor you can simply use the search box.

Thanks robertbu NOTE, I think you added your reply as a comment, so I'm not able to set it as the accepted answer and BoredMormon I'll try the search box suggestion

1 Answer

1

FindObjectsOfType():

You’ll have to go through the list and find the ones named Blue.