So I’ve had this issue for a while, since 2021.3.1 perhaps? Anyway, occasionally this will happen and Unity will be stuck on “Reload Script Assemblies” forever. Typically I’m only waiting a few seconds for this. I have no idea why this happens, at first I thought maybe one of my scripts is causing it? But it’s very inconsistent and I can’t reproduce it, it just randomly happens.
Screenshot of it attached. The only way for me to break the loop is to make a change in any of my scripts, save and it will recompile. Then it may or may not happen again afterwards.
Hmmm just a few thoughts. I’ve had this too but it was either running out of memory, accidentally doing nasty stuff with Native collections, or quite simply: editor scripts. The latter can cause issues in particular when you hook into assembly reload events or initialize on load where you create, delete or modify assets, scripts in particular. I deadlocked myself once by modifying a script during assembly reload and I had a bug there that caused the generated script to be changed on every reload.
I started having this issue suddenly where my reload script assemblies went from averaging about 12 seconds on a fresh restart to over 2 minutes. Neither restarting nor rebooting the computer helped once it slowed down.
There is hope. At least for others who might be experiencing this issue for similar reason to my own. I searched the forums trying to find a quick fix and nothing posted seemed to help but I did see comments about the editor scripts that could cause problems (like codeSmile and a few others mentioned). I opened up the Import activity window (Unity 2021+ feature I believe) and noticed a few long loading delays with prefabs that had an editor script attached to it that I had recently worked on. I redesign the editor script where I was referencing a monobehavior class which in turn held a reference back to the editor script’s underlying class. I’m not certain this change fixed my problem but I believe it did because with that code change and deleting all but the one prefab referencing this script my script reload times went from over 2 minutes to under 10 seconds. A speed improvement over where I started the day.
Particularly such editor scripts or generally any script that has [AlwaysExecute] or [ExecuteInEditor] attached or subscribes to editor events (assembly reload, selection change, and so on) have quite often been causes of slowdowns in my past experience.
Some devs are quick to blame Unity yadda yadda but my stomach feeling is always that the most likely cause is either self-made or simply imported assets that do not scale performance-wise (or have been misused). I would always recommend to analyze the issue first, like you did!
I
"Reload Script Assemblies*
also have this problem when
"Reload Script Assemblies*
working with Unity in the last couple of
"Reload Script Assemblies*
years . It never used to be a problem before, I have
"Reload Script Assemblies*
been using Unity since 2012 quite
"Reload Script Assemblies*
happily but now it
"Reload Script Assemblies*
seems to make everything exceedingly slow and
"Reload Script Assemblies*
frustrating. If I even touch anything I can expect to wait for several seconds. It seem that all the years of constant
"Reload Script Assemblies*
product “improvement” and investment have
"Reload Script Assemblies*
resulted in a software that has a wider range of possible
"Reload Script Assemblies*
uses but has become almost laughably
"Reload Script Assemblies*
user unfriendly. Its almost as if the developers of this software
"Reload Script Assemblies*
didnt actually consider testing it
"Reload Script Assemblies*
with actual
"Reload Script Assemblies*
users.
This never used to be a problem with
"Reload Script Assemblies*
Unity 2019 or earlier.
Perhaps only because Unity 2019 never shoved a “Hold on …” progress bar in your face. That progress bar was added in Unity 2020.2.
In any case, if the issue is so persistent and slowing you down, you need to analyze it. If it feels unusual, it usually is. Quite frequently I find that the culprit are badly written editor scripts. I made it a point to go over the code of every asset that I seriously intend to use in a project, but one out of four or five I have to throw back out, seeing that the code will likely break, will not be debuggable or extendable, or may significantly degrade editor performance like any code that runs AssetDatabase.Refresh in a common event, or even in update.