Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Execution Start Order

Discussion in 'Scripting' started by davej256, Nov 25, 2022.

  1. davej256


    Nov 11, 2022
    Suppose I have 100 different GameObjects in my scene. They all share the same script. If I compile a build and share it with 10 friends, will those scripts start in the same exact order on all of their machines?

    What about a server and client build?
  2. olejuer


    Dec 1, 2014
    No, and you can find the answer in the manual.
    "[...] The order that Unity calls each GameObject's Awake is not deterministic[...]"

    Use an initialization script that references your objects in a list or array and have it call some Init() method sequentially, if you really need that.

    You should, however, think again whether you can find a better design that does not rely on the order of those calls.
    Bunny83 likes this.