Children added at runtime not accessible!?!?

I’m adding some objects to the hierarchy at runtime by setting the ‘parent’ of the transform. The object appears in-scene, and in the hierarchy view. But no way can I access this new child. Cannot find components either!


function Start()
 var par = GameObject.Find("MyParent");
 var kid = new GameObject("kid");
 var mf = kid.AddComponent(MeshFilter);
 mf.mesh = myMesh;
 kid.transform.parent = kid.transform; // so far so good, things appear as they should

function Update()
 var par = GameObject.Find("MyParent"); // (I normally don't use Find in Update)
 // par is ok
 Debug.Log("Parent's # children:"+par.transform.childCount); // ZERO children
 for (var t:Transform in par.transform)
  Debug.Log("This never happens, no children!?");
var rs : Renderer[];
rs = par.GetComponentsInChildren(Renderer) as Render[];
// rs is NULL because it found none

Is this a bug or have I been missing something?

Was a timing issue. My Object had not fully loaded before I was trying to access it.