I was wondering what the proper Unity way of calling Dispose and assetBundle.Unload were?
If I Instantiate a gameObject using assetBundle.Load() and then Destroy it later do I have to keep references to the original www.assetBundle and the www class to call Dispose and Unload after Destroy(gameObject)?
Simple example below.
IEnumerable Download(string url)
{
myDownloader = new WWW(url);
yield return myDownloader ;
myObj = (GameObject)Instantiate(myDownloader.assetBundle.mainAsset);
// should Dispose be called here?
// if it is IDisposable won't that only clear unused references?
}
void DestroyDownloadedObject(GameObject obj)
{
Destroy(obj);
myAssetBundle.Unload(true);
myDownloader.Dispose();
}
// do I need to keep the AssetBundle and WWW reference?
AssetBundle myAssetBundle;
WWW myDownloader;
GameObject myObj;