Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    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.