This error is a bit hard to explain, but here’s what’s happening:
I can work in the editor and have no issue. Everything works fine. Once I move to a different app (like Photoshop or Maya or Visual Studio) and work for a bit, occasionally Unity will lock up for a while. It usually regains control after about 30 seconds, but it slows my work down a lot. This can be fairly irritating when making a small change in Visual Studio since I have to not only wait for Unity to respond, but I then have to wait for scripts to compile. Sometimes I’m waiting upwards of 2 minutes for Unity to come back.
I also cannot click out while waiting to respond since it kind of resets everything. If I click out while scripts are compiling, it can become a nightmare. I’ve had to wait 10 minutes once for Unity to respond again.
As for my system:
Windows 10
Intel i7 6820HK
16GB Ram
GeForce GTX 980M
Sounds like you might be editing project files outside unity (like editing a texture in photoshop, a model in maya, scripts in VS) and then when you return to unity, it must import the changed files it noticed had been edited, and this typically takes only a few seconds for a smaller asset, or up to many minutes for larger assets (especially huge textures), but judging from the machine specs your using, I’d guess it shouldn’t take very long for you, at most a few seconds on even the largest SINGLE file, of course that would be longer if you edit many files at once, then return to unity, as it must reimport more things. Even editing a large script file can cause a slowdown for unity while it reimports the script.
Does this sound right? I’m just guessing here, but that is pretty much all I can think of. Anyway if not, maybe let us know if your system has antivirus and stuff, because malware could easily drag your computers performance way down, or perhaps just a pile of heavy background processes even could make this take much longer than it should.
Do you notice a little spinning circle in the bottom right corner of the editor? This is a sure sign the import process is what is slowing you down.
EDIT: oh another thing that can cause lag when returning to unity after editing scripts is google play games services and similar assets which “auto update” and do other background tasks each time unity reimports assets (GPGS has to do this incase an update has been made available for the plugin, other assets do this for other reasons). Just another thought…
EDIT 2: oh thought of something else… what happens when you leave unity in the background a while but don’t edit any scripts or assets… does the editor come back like normal when it doesn’t import any changes? If it lags in this situation (not reimporting anything) then that would be a sign something is either wrong with your unity installation or the stability of your OS. Or, maybe your project is just really very large (many gigs of assets) and has to scan lots and lots of tiny to large assets for changes and as a result gets very sluggish on reimport.
EDIT 3: ok last afterthought haha - perhaps you use editor scripts that create/do work on assets in the editor (like for instance a level generator editorscript) and it might leave tons of variables in memory that are “lost” references to, and by simply restarting unity every so often and “cleaning up” that garbage, you might see improved performance. One way you might be able to tell if this is something your project suffers from would be if you notice strangely long load time to switch between scenes. (very large scenes that always take forever to load don’t count)
My project file is massive - over 40GB and switching between scenes does take a great deal of time in the editor. It’s not something that I do very much since most of my game takes place in one scene with the rest of it being loaded additively.
Yes, this delay does happen even when I have edited nothing. I have re-installed Unity as recently as a week ago and even re-formatted and re-installed Windows about a month ago with no real change in performance here.
I also have a HUGE amount of editor scripts on an incredibly large amount of objects. I leave them in the scene so I can edit things quicker at runtime.
So yeah it sounds like all of these probably contribute to this issue at varying degrees.
As a side note, restarting Unity does seem to help for a short period of time, but I prefer to not restart as my project takes 3-5 minutes to open and upwards of another 5 for the first successful play test.
Knowing that I can probably alleviate some of this by trimming some of the unneccesary things out is good, but I’m probably just going to have to live with this issue for now.
I figure those editor scripts are part of the root problem, as I do the same thing (well not leaving in scenes… not sure what you mean by that, those sound like component scripts) where I use editor scripts and do lots of work in batches, and it ends up leaking memory like crazy, where if I won’t restart unity after so long, switching scenes becomes very heavy (well at least on 5.3.x it did, this seems somewhat better in 5.4.x I recently updated to) and I would be eventually forced to restart unity and then things would go back to normal load times on import and all.
Well hope I helped somehow haha, good luck sorting everything out!
When an process tries to allocate memory (RAM) and the system does not have enough ram to satisfy the request it will “swap” other processes to disk (take their in memory state and write that to swap space (typically stored on your system HDD/SSD)). Some refer to swap space (I’m a linux guy) as “Virtual Memory” or “Paged Memory”. When you return focus to the “swapped” process it the OS must load the “swapped” state from disk back to RAM. Disk read/write speed is orders of magnitude slower than reading/writing from RAM so you’ll experience delay while it does this work behind the scenes.
You can inspect your “Task Manager’s” performance tab to see the load on the system, real memory free. On windows swapped memory I believe is referred to as ‘paged’ (not 100% sure on that).