Update() maybe called at “random” order.
But if a gameobject is a other gameobject’s child,is the Update order predicable?
First called update in all children and then called update in their parent as the same as Start()?
Very thanks!
Update() maybe called at “random” order.
But if a gameobject is a other gameobject’s child,is the Update order predicable?
First called update in all children and then called update in their parent as the same as Start()?
Very thanks!
Don’t bet your life on this: I created a simple test script and attached it to several objects. They seemed to follow the “women and children first” rule, but things changed when I added two new children to the parent: another “external” object entered the order, messing things up. The script I added to the objects is:
static var updateOrder = 0; var order = 0; function Update(){ order = ++updateOrder; } function LateUpdate(){ updateOrder = 0; }
I just watched the order variable of each object in the Inspector to learn the sequence its Update was called.
You can define scripts execution order in Unity 3.4: select the script in the Project view and click the Execution Order button in the Inspector.
I honestly don’t know how multiple instances of the same script are ordered, but hope this may help solving your problem.