- Home /
Unloading an asset loaded via Resources.LoadAsync
If I try to use Resources.UnloadAsset() to unload a prefab that was loaded with a call to Resources.LoadAsync(), I get the following error:
UnloadAsset may only be used on individual assets and can not be used on GameObject's / Components or AssetBundles UnityEngine.Resources:UnloadAsset(Object)
Is there another way to do this? Is it not possibly to unload an asynchronously loaded prefab? Is this perhaps a bug with the new Resources.LoadAsync() method?
Answer by smoggach · Sep 22, 2014 at 01:49 PM
The prefab itsself isn't the actual resource, it's the assets that it depends on. The best way to unload something is to first ensure there are no references to it by setting any to null. Then call Resources.UnloadUnusedAssets. Trying to unload it directly is more tricky than it's worth.
You may also try Destroying your gameobject instead of trying to unload it.This will set any references it has to null.
Your answer

Follow this Question
Related Questions
Level Editor in Unity as Editor Extension 1 Answer
Saving changes to the asset files for Prefab and Scriptable objects. 1 Answer
Is it possible to get a prefab object from its asset path? 6 Answers
Getting properties on 'missing' things in Editor Scripts? 4 Answers
Can I safely put a prefab asset into version control with Unity Free? 3 Answers