4

I'm new to Unity5, and I'm trying to create a simple game.

By extending MonoBehaviour, I receive an Update() function. But I don't know how it works behind the scenes.

My question is, are the Update() functions serialized (called one after the other) or parallelized when many MonoBehaviours have their own Update functions.

For example, if I have two scripts with its own Update in each, would the Updates be called at the same time (parallelized) or are they called one after the other (serialized)?

If they are serialized, how do I determine the order?

user121292
  • 43
  • 4
  • 2
    They are not paralleled because the Unity3D API is not thread-safe. So when the API calls into your `Update()` it must do so from the primary thread. http://answers.unity3d.com/questions/7524/is-the-unity-api-threadsafe.html –  May 22 '15 at 06:12

1 Answers1

6

By default, new MonoBehaviour scripts are executed in whatever order Unity compiles them into. They are not run at the same time, they run one after another.

If you want to specify the execution order, you can do so under:

Edit > Project Settings > Script Execution Order.

Further reading: Execution Order of Event Functions

Chris McFarland
  • 6,059
  • 5
  • 43
  • 63