How to set parents of all objects in an array?

Hello all,

I am trying to parent all the gameobjects in an array to a single parent. I have got all the objects in an array via

GameObject.FindGameObjectsWithTag

and now I want to change the parent of all of them. I tried doing this by getting the array

(var parts : GameObject )

and then using parts.transform.parent == parentobject.transform.

I wasn’t expecting this to work, but I did try it. I then set up a system where Unity loops, and parents the gameobjects together. This worked, but with the large number of objects in the array that needed parenting, this is taking 10-20 seconds. I need this to happen in a single frame. Does anyone have an idea on how to do this?

javascript only, please

thanks

You need to iterate through the array and set the parent of every object. That’s always how you do stuff to multiple objects, for anything. There’s no way it should take anywhere remotely near 10-20 seconds, unless by “large number” you mean “really absurdly huge ridiculous number”, in which case the only thing you can do is reduce the number of objects.