Hi everybody,
I have a custom AssetBundle management system to load external assets. Everything works peachy until I realized one thing: how do I know when I can safely unload an asset bundle with unloadAllLoadedObjects param set to true, to free up some memory?
I know I want to do this only when loading another scene. But the problem I see is that I don’t know if any of the assets inside an asset bundle are in use or referenced in any script in the current scene.
Is there a way to find out if an asset from an asset bundle is in use or referenced in a script in the current scene?
I was thinking about using FindObjectsOfType( … ) to search for all the assets of the same type as the asset I want to investigate and then go through the returned array to check this with the == operator to see if I find it. But I think you see the problem here: there could be different instances of that asset, so the comparison doesn’t help here.
But, if I unload an asset bundle with the unloadAllLoadedObjects param set to false, will Unity auto clean unused loaded assets from the bundle upon loading another scene? Or they will just remain in memory for ever and ever until death (Out Of Memory crash) do us part. ![]()
Any advice is appreciated!
Thank you so much!