Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Questions about scripts execution order

Discussion in 'Scripting' started by belpory, May 24, 2024.

  1. belpory

    belpory

    Joined:
    Mar 21, 2024
    Posts:
    19
    Let's say I have two gameObjects in a scene. Both of them have the same script.
    Does one run the script and then the other?
    Or the two run the code at the same time?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,391
    One runs, and then the other runs. The core of Unity that we use is single-threaded. Though this order isn't deterministic.
     
    Spy-Master likes this.
  3. belpory

    belpory

    Joined:
    Mar 21, 2024
    Posts:
    19
    thanks, but what is single-threaded?
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    You know what multithreaded is?

    Multithreading means things can run in parallel. Singlethreading means they can't, every method runs consecutively.
     
  5. belpory

    belpory

    Joined:
    Mar 21, 2024
    Posts:
    19
    Thanks