This problem really bugs me for many years now. When I watch Youtube videos of people compiling code in Unity and then starting it, there is hardly any delay. However when I just change a single line of code, save and then want to start, it takes roughly the following times:
10s until the Editor is refreshed and I can potentially hit the Play button
9-12s from clicking the Play button until the app actually starts (it’s rather small)
3s when I stop the game by hitting the Play button again
That’s 20s everytime I change a single line of code and want to check the results. That’s just not cool Build and Run on my phone: 3min (30MB apk, building takes~2min)
From my feeling, this got worse as I installed newer and newer versions. Right now, I am using 2018.3.3f1. And no, problems are not always fixed by installing new versions I had this issue for older versions, too.
Although my system is 10 years old, it’s still good hardware (8 cores, 16GB RAM, gaming GPU).
Can someone tell me how to improve compilation and start/stop times or why this problem exists?
10 year old 8 core CPU? Really? When you say 10 year old computer, I’m suspicious that the issue is hardware still.
But the amount of time these operations take depends on the size and complexity of your project, as well as the currently opened scene. My understanding is when you hit Play it takes all currently opened scenes and saves them all to disk in temp files. If they are big that will take longer, if your computer is slow that will take longer. When you exit Play mode Unity throws out the open scenes and restores the scenes from the previously saved temp files. This is why when you make changes to the scene in Play mode the changes are reverted when you exit Play mode.
As far as when you save a code change and go back to Unity, that triggers a recompile. How long a recompile takes depends again on your project and your hardware. I believe the compile process is fairly single threaded, so poor single thread performance will impact how long it takes. I can’t imagine a decade old CPU having good single core performance, as 8 cores was a high core count at the time and typically CPU’s with high core counts actually have lower clock speeds than their lower core count variants, making single core performance a weakness. (as an example, look at specs for Xeon CPU’s vs desktop in the same generation, you will see significantly lower clock speeds on the Xeons)
Memory speed was significantly slower a decade ago, which probably has an impact on this as well.
“at that time”??? Is it not a lot still?
I fully agree to all you are saying and had the same thoughts. But my project is small and there are no complex issues to be done or big scenes/assets to be loaded.
If it was GPU related, I could play around with my GPU Tweak, but I assume same as you that this is a single-thread bottleneck problem.
Also, why does it take like 10s to update a 2048x2048 image because a new version was created on the filesystem???
Or if I change the sprites in Sprite mode multiple - how can this possibly take longer than 0,1s?
Deleted a script file. 20s later, I can finally work on…