Workaround for EditorUtility parenting bug

I can’t do

GameObject tempPrefab = EditorUtility.InstantiatePrefab(//a prefab) as GameObject;

and then later

foreach (Transform child in tempPrefab.transform)
		child.parent = //a transform;

because the parenting gets cut off at 16 game objects (and ones whose names end in odd numbers don’t move).

Does anyone have a good solution?

(dreamora’s next comment was made when this last line of pseudocode said //a game object instead.)

parent expects a transform, not a game object as it is an aspect of the transform hierarchy.

in the loop you have it right for the left side but the right side is wrong.

the compiler actually should tell you that too.

Sorry, I wrote that when I just woke up. What I said is happening, can’t happen, if I didn’t actually use a transform.

// The recursion is currently necessary. 
// I will have reported the relevant bug later today, September 23, 2009
bool reparenting = true;
while (reparenting)
{
	if (transform.childCount > 0)
		foreach (Transform child in transform)
			child.parent = anotherTransform;
	else
		reparenting = false;
}