Undocumented Unity Function
So, you’ll find the childCount property documented, but what you won’t find in the documentation is GetChild(). According to the forums, the reason it’s been left out is because of unpredictability – the array of children is not guaranteed to be in a consistent order. However, that’s not to say that it can’t still be useful – you can get the idea of where I’m going with one concept from the snippet below. Or do tag compares or component checks to affect certain children.
Maybe it would have been better for the docs to let me decide for myself whether or not to use a piece of code.
void Explode()
{
for( int i = 0; i < transform.childCount; i++ )
{
transform.GetChild(i).gameObject.AddComponent( "Rigidbody" );
}
}

A nicer way to do this is actually described in our docs. Here’s the gist of it:
for (var child : Transform in transform)
child.AddComponent(“Rigidbody”);
Less code, and cleaner too (and anything that uses undocumented functions in Unity is prone to breakage, as “undocumented” in Unity also means “subject to change”).
Not that there’s anything wrong with what you wrote, but any code that uses the “i” iterator for something would be very prone to breaking.
Best regards from GDC!
d.
Fair enough.
Sounds like GDC went well, very excited to see what effect a new crop of PC developers will have on web plug-in saturation. I think there will be a lot of opportunity for simulations, serious games etc. once acceptance of Unity online spreads.
I appreciate you taking the time to stop by.
Vergil