Two monobehaviour scripts attach to one gameobject and the Update order predicable?

If I attach two monobehaviour scripts to one GameObject,is the Update order predicable?

For example:
First I attach aaa.cs and then attach bbb.cs, unity engine will call
aaa.Update()
bbb.Update()
??

Very thanks.

3 Answers

3

Update is called once per frame, I don’t think that you would be able to predict which script is called first. Just did some testing and the script I attatched to the game object last got called first, but this can also be random, I’m not sure at all. May I ask what you need this for? :slight_smile:

You can set the script execution order in Unity, which according to the 3.4 release notes
includes Update() commands.

Tutorial on how to set this is [here] 2

The order in which Update is called is undefined, so no, the order is not predictable, unless you use the script execution order which MIke mentioned.