Destroying Resources and then calling UnloadUnusedAssets not unloading textures

I’m loading up prefabs stored in the Resources folder, like so:

this.oneTimeMenu = GameObject.Instantiate(Resources.Load("ScriptPrefabs/Menu/oneTimeMenu")) as GameObject;

Then when I’m done with the menu I’m doing this:

Destroy(this.oneTimeMenu);

Now I’m waiting one game loop and then calling this:

Resources.UnloadUnusedAssets();

Now, in a perfect world, when that is done all textures that were part of the oneTimeMenu prefab should be unloaded. But they aren’t. If I do this:

Texture2D[] allTex = FindObjectsOfTypeIncludingAssets(typeof(Texture2D)) as Texture2D[];
foreach (Texture2D thisTex in allTex)
{
     Debug.Log("---*** Texture " + thisTex.name);
}

I can see that the textures are still there. Does anybody have any idea what I’m doing wrong?

Anybody? Our game is crashing on iOS hardware from running out of memory, and these textures are a big part of it

Just found this post, and I suppose you got the solution in the meantime. Just posting it for future references.

Resource.UnloadUnusedAssets() doesn’t unload assets that are still referenced somewhere. Setting this.oneTimeMenu to NULL after destroying it should do the trick.