So I have noticed this lately but I can’t explain why…
When I put a fresh build of my game on my iPhone 4, the first time I load a level (go through UI, select level to play > load that level), the load time is around 10 seconds. Then I exit the level, go back to the level selection screen, and load any level (same level or other level doesn’t matter), my load times go down to 2-3 seconds tops!
At first I though that maybe it was caching the assets for that level, and when loading it again, it was faster because the assets were ready, but I don’t think that’s the case, because it doesn’t matter which level I load first, ALL following level loads for ANY level are much faster.
If someone could enlighten me I would really appreciate it!
Thanks for your time guys,
Unity’s compiling shaders for you. See:
(Note that API allows you to warm the shaders up. Your delay is Unity doing this before the level plays the first time. The API won’t help you, I just use it as a way of teaching you what happens.)
Well I realized that my MaterialManager as a link (dragged and dropped in editor) to a substance, so that’s why they’re being used. What I still don’t understand is why the other 10 substances are being compiled since I don’t use them anywhere.
Anyways, here’s a post I found about substances and loading times:
Substances Long Load Times
The last post reads:
"Just to ensure thats kept in mind: Prior to Unity 4.1, there was no support for dynamic substances in mobile targets at all!
If you used substances in Unity 4.0 and earlier for a mobile target, they were baked upon export, there was 0 runtime allocation and 0 disksize saving, all you got was an easy, consistent cross platform development.
This indeed means that it will now take significantly longer at runtime if you decide against bake at edit time (which was what it did before 4.1)"
So yeah no wonder my load times went up all of a sudden with Unity 4.1, would be nice if they warned us about this!
So I pinned down the problem to Substances!
I have a folder with a dozen Substances in my Project, and if I remove this folder and make a new build, the 10 seconds hold goes away…it’s compiling Substances! The weird thing is that none of my assets in any of the levels I’m loading use Substances, so I don’t understand why they are getting included in the build, and especially why they are being processed since no assets use them?!?
So the good news is that I finally figured out what the problem was, the bad news is that I don’t understand why the problem is happening in the first place