UnloadUnusedAssets is called before or after read a new level?

I read in some references this statement “Loading levels calls Resources.UnloadUnusedAssets”. UnloadUnusedAssets is called before, or after read a new level?

There is some oficial documentation about it?

EDITED: Add more specifc information

In the case of Application.Loadlevel. What exactly happens? I can see some possibilities:

a) Before load new scene: I don’t think so, because it could cause all redundant assets need to be loaded again.


Scene1: TexA, TexB
Scene2: TexB, TexC

During the transition of Scene1 to Scene2: TexA and TexB are unloaded, Scene2 is loaded, and TexB and TexC are loaded. You never have more that 2 textures in memory, but you load TexA twice.

b) After load new scene: It will only clean assets that will not be needed anymore after load the new scene.


Scene1: TexA, TexB
Scene2: TexB, TexC

During the transition of Scene1 to Scene2: Objects from Scene1 are deleted and Scene2 is loaded, TexC is loaded, after execute the clean up the TexA is unloaded. Simple and efficient, but during the transition you have the sum of two scenes, in the example, you have 3 textures in memory.

c) memory threshold is exceeded: Like b), but it clean up if needed during the load


Same as b), but if receive a low memory when try to load TexC, it execute the unload assets first, working like a)

I am asking it because I am trying to tune our app to play nice in IPod4, with is limited memory. And I am having problem during big scene transictions, like game to menu, both use a lot of memory for textures, but different ones. It is not a big problem, it unity3d is sufficient smart, but I would like to understand better for further optimizations.

I’ve got this from on a conversation with Joachim Ante, CTO of Unity:

As of Unity 4.2,
Resources.UnloadUnusedAssets is called when:

  • Enter playmode
  • Importing assets and a memory threshold is exceeded
  • Selecting objects one after another and a memory threshold is exceeded
  • Opening a scene in the editor
  • Application.Loadlevel or Application.LoadLevelAsync

Note: Additively loaded scenes do not trigger UnloadUnusedAssets.

No answer, I will answer myself what I feeling.

I think that it is executed after load the new scene. It is simpler to clear everything not used in a scene that compare what will not be used in next scene to be cleaned.

If it is true, during a scene loading the memory used is the sum of all assets in both two scene, until the UnloadUnusedAssets get rid of all unused assets.