I have an issue with optimization that to me seems strange.
I have a scene with lots and lots of game objects with sprite renderers attached. It’s a 2D pixel art game. Whenever I load this scene, I have to wait a while while Unity thinks.
I thought maybe my scripts were causing it to freeze. I’m still not heaps confident with the profiler though a friend said it looked like it was the Garbage Collector.
Well, the weird part is, I deactivate all of my scripts, I get a slightly faster load time but no real difference. If I physically remove the scripts, the scene loads instantly. I can’t see how deactivating and removing the scripts would provide such a big difference.
Nothing is being instantiated, and I’m not accidentally turning those scripts back on. Any ideas and explanations why removing the scripts makes it so much faster whereas deactivating them doesn’t? I feel like there’s some under the hood Unity stuff going on that I don’t understand.
Furthermore, all of the scripts that I removed, well I put ‘return;’ at the start of the “start / Awake / OnEnable” functions to make sure they weren’t doing anything, and in update, and that didnt’ help either - just to be sure the scripts weren’t doing stuff.
There are quite a few game objects in the scene, with lots of children, and those children mostly have scripts attached, so a very high number of scripts are in the scene prior to removal. At a guess, 100 or more scripts removed to get the improvement.
The majority of the game objects start as “Inactive”, set that way in the Scene Editor, and the scripts pretty much all use “Start” or “OnEnable”, nothing is happening in “Awake” in the scripts I removed