Hi, I'm making a iphone rpg and finally came to meet memory doom and need to figure out a way to load and unload textures dynamically. The problem is I couldn't find a way to unload textures without stopping the game briefly and it does not look good at all.
I load texture of one item like below.
I googled around and my only option seems to be Resources.UnloadUnusedAssets().
I tried Destroy(ItemGameObject) which holds the only referece to Texture2D and GC did not collect it (Some post says losing reference to texture will unload it and some post says GC does not handle textures which is confusing to newbie like me)
I experimented myself with really big texture so that I can clearly see if it is being loaded and unloaded and Resources.UnloadUnusedAssets() only worked.
It'd be much appreciated if experienced Unity programmer could help me on this one.
To allow GC to release the memory, destroying the GameObject with
For example, if you have a script with:
The best way to do that is to use the
You can call GC explicitly with:
answered Apr 10 '12 at 12:01 PM