- Home /
 
GameObject Parent-Child instantiation order
Hey all,
I just started using Unity, so I apologize if this question's a little noobish. I was just wondering if anyone knew what the order of instantiation is between a Parent GameObject and its children. I know it's random by design between all root GameObjects, but if a GameObject has children, can I be guaranteed that they are instantiated when the Parent is?
To illustrate, if this is the Start method of the Parent GameObject,
    // Use this for initialization
void Start () {
    Mesh SomeMesh = transform.Find("ChildName").GetComponent<MeshFilter>().mesh;
}
 
               
               Can I be sure ChildName is always initialized, and Find won't return null?
Answer by Jesse Anders · Feb 24, 2011 at 05:03 PM
By the time Start() is called, all objects should have already been created and initialized. So, what you have there should be fine.
But you can't depend on children being already instantiated on Awake() ?
Answer by jasonrlund · Jan 07, 2014 at 05:26 AM
Right Jesse, but Endesmomo is asking about the relationship between parent GameObject's and their associated children when it comes to their initialization order; i.e. do children get initialized THEN parents, or to parents get initialized THEN children, or is there no guarantees as to this order? I too have this question.
Your answer