Script execution order
Scripts are not executed in a random fashion: script type, script location and script settings can influence when (in relation to others) a script is being executed. A simple rule to remember is: the more important or persistent a script is, the later it will be called/executed.
Execution order is first based on script type. We have following order, from first executed to last executed:
Because child scripts are simulation scripts, they will only run as long as the simulation is running (i.e. they are not persistent). This is not the case with customization scripts, add-ons and the sandbox script, which run also after a simulation stop. Additionally, add-ons and the sandbox script also continue to run when switching to a different scene. Above sequence makes sense since important scripts can be designed to rely and operate on data produced by less important scripts.
As an example, the callback sysCall_sensing will be called in following sequence: first in child scripts, then in customization scripts, in add-ons, and finally in the sandbox script.
Within a script type, the execution order is a function of a script's position in the scene hierarchy, and its following 2 script settings:
[Script execution order based on execution priority setting]
[Script execution order based on tree traversal setting]
Following diagram illustrates a concret example scene:
[Example scene and child script execution order]