I’ve been trying to unload the asset I load using Resources.LoadAsset with something similar to the following code:
LevelData thisLevel;
void Start(){
thisLevel = (LevelData)Resources.Load (levelName, typeof(LevelData));
// Get the proper variables and do some work here
Resources.UnloadAsset (thisLevel);
}
The error I’m getting is the following:
Aside from the fact that this may be bad practice (in this scene, I’m loading and unloading multiple assets on different objects, so I want to unload them as soon as possible to empty memory for the mobile device), I can’t get this to work in other instances (ie at the end of a level). The best information I could find was from here:
In the link above, one person mentioned you had to destroy the object, call to unload the asset, and ALSO call UnloadUnusedAssets. However, destroying thisLevel doesn’t even work at all (throws another error about destroying an asset).
Any help here? Or should I not even worry and just use UnloadUnusedAssets at the end of every level? (assuming it unloads all assets that I used without the need to do UnloadAsset).
Thank you!