This is probably more of a Unity question than an NGUI question, however I am curious as to how the objects are stored in NGUI and how best to traverse the child list if I am planning on doing an algorithm every frame.
Let's say I have these 2 algorithms:-
____________1___________
for (int i = 0; i < transform.GetChildCount(); i++)
{
transform.GetChild(i).renderer.material.SetColor("_Color", new Color(1.0f, 0, 0, 1.0f));
}
_______________________
____________2___________
Transform[] transform_list = myobj.GetComponentsInChildren<Transform>();
foreach (Transform the_t in transform_list)
{
the_t.renderer.material.SetColor("_Color", new Color(1.0f, 0, 0, 1.0f));
}
_______________________
Now off the top of my head I am thinking that algorithm 2 is faster because in 1, the GetChild is being called every frame (and perhaps is also being evaluated each time in the for loop as well). However algorithm 2 requires an allocation of memory for the list, so hmm, not sure which is best.