- Home /
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.
Answer by Artifactx · Feb 21, 2012 at 01:16 AM
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? :)
Answer by runonthespot · Feb 20, 2012 at 05:29 PM
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
Answer by Eric5h5 · Feb 21, 2012 at 01:27 AM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613064257im_/https://answers.unity.com/themes/thub/images/avi.jpg)