Unloading unused assets automatically?

While debugging my latest build in XCode, I noticed the following message popping-up whenever I load a new scene:

Unloading 25 unused Assets to reduce
memory usage. Loaded Objects now: 245.
System memory in use: 0 B. Unloading 2
Unused Serialized files (Serialized
files now loaded: 0 / Dirty serialized
files: 0)

How can I find out which assets are being unloaded and why? I am not doing any unloading on purpose anywhere yet, so I’m curious as to why this is happening…

As always, thanks for your time and help!
Stephane

Slightly out of topic, but do you have a problem with your splash screen on your iPhone app? When I play my game on my own device it gets stuck on the splash screen.

I had a few hangups on the splash screen before but it was because of a bug in my code or a build with missing files. Other then that, I never get stuck on it

Hmmmm... well thanks for answering.

Hi is there a way to avoid certain assets form being unloaded when the assets.unloadunusedassets is called ?

1 Answer

1

Loading levels calls Resources.UnloadUnusedAssets, to clean up memory used by assets no longer needed for the new level. This is expected, and needed so you won’t eventually run out of memory when you are loading lots of levels with lots of assets.

Thanks for the answer jonas! Quick question, how can I find out which assets are being unloaded?

There's no way to list the assets being unloaded. However, you could do FindObjectsOfType(typeof(Object)), and compare the results before and after loading a level to find out.

Good idea! Thanks again