Search Unity

Question Extremely long wait time when entering/exiting playmode?

Discussion in 'Editor & General Support' started by MELTPACK, Apr 3, 2021.

  1. MELTPACK

    MELTPACK

    Joined:
    Apr 7, 2017
    Posts:
    151
    Recently my project has been suffering massive wait times, normally when entering/exiting playmode. It can sometimes take up to 18 seconds!

    Profiling this, it shows that ReloadAssemblies is taking the most time. Is there a way to fix this?

    I heard that having lots of FindObjectsOfType<> and scriptableobjects in your code can contribute to this. Anyone else had experience with this?
     
  2. MELTPACK

    MELTPACK

    Joined:
    Apr 7, 2017
    Posts:
    151
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    A project on slow storage, such as an HDD, also contributes to this (or any slowness related to disk operations).
     
  4. MELTPACK

    MELTPACK

    Joined:
    Apr 7, 2017
    Posts:
    151
    I'm on an SSD. Even when I was on a HDD, it never took this long!
     
    alpbabil likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Maybe see if using the Profiler and setting it to "Editor" shows you something?

    I mentioned storage before, because one of the things the Editor does when you click Play is it writes all scenes currently active in the Hierarchy to disk as temp files. This is so when you exit play mode, the state the scenes were in will be restored from those temp files. 18 seconds sounds very long, but the size of the scenes, and your hardware performance, will affect how long it takes.
     
  6. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    18 seconds?! I wish! Try up to a minute for size :)
    Should seriously schedule some profiling to the enter/exit times i think ha.