var objects = GameObject.FindGameObjectsWithTag("ObjectTagName");
for (var i : int = 0; i < objects.length; i++)
{
objects*.GetComponent(nameOfComponent).DoSomething();*
What I would do is add the objects to a collection as soon as they are instantiated. Then you can easily loop through the collection. You can make the collection add items of your script type, because then you don’t need to GetComponent. You can cast it immediately upon instantiate…
… provided that the prefab has the component attached, ofcourse
// and loop somewhere
for (int i = 0; i < myListOfTypes.Count; i++)
{
myListOfTypes*.DoSomething();*
} Depending on when and where you do FindGameObjectsWithTag(), it can have an impact on your performance. If however, you cannot use permanent collections (due to memory restrictions) then, by all means use FindGameObjectsWithTag once, map to array and loop through that.