- Home /
How can I unload a single resource?
I can use Resources.Load(path) to load a single resource file. How can I unload it?
Object.Destroy says I can't destroy an asset
Object.DestroyImmediate destroys the resource, and the underlying asset, and requires me to re-import in the editor (surprise!)
Resources.UnloadUnusedAssets doesn't let me pick which resource to unload
Should I just use UnloadUnusedAssets anyway?
Resources.UnloadUnusedAssets seems to be a frame rate killer, so I'd like to avoid if I can.
And yes, I believe AssetBundles would solve the problem, but I'm using the free edition of Unity, so AssetBundles are not available to me.
Answer by Datael · May 16, 2012 at 06:43 AM
A new method has been added in Unity 3.5.2 that should do what you are after:
Resources.UnloadAsset(Object asset);
Except it complains that it can't be used on a GameObject :(
Answer by StephanK · Apr 26, 2010 at 09:57 AM
Thanks for the link. The thread suggests using Destroy to unload assets ("You need to Destroy() assets and remove all references to them in order to clean the memory after loading them."), but as I mentioned above this technique doesn't work. I suspect it would be the right approach if I was procedurally generating the assets, but for my use case it doesn't work.
Your answer
Follow this Question
Related Questions
Access path of stored asset 0 Answers
Create JPG to HDD from Image In Assets-Folder 0 Answers
What are the minimum file types I'll need to import for using 3d assets? 1 Answer
Resources.FindObjectsOfTypeAll() doesn't return all Textures 2 Answers
GameObject permanent destruction from "Resources" in EditorWindow 0 Answers