- Home /
Object parent Asset Bundle
Is there a way to know from which asset bundle object was instantiated? Assume I've got web player project with world divided in scenes that are stored in bundles via BuildOptions.BuildAdditionalStreamedScenes. I load the scenes with WWW class and load them additive. Scenes are loaded when player approaches their world location. After scene loads the bundle is not needed anymore and I unload it along with corresponding WWW, _assetBundle.Unload(false) leaves already instantiated assets intact. Yet later I want to delete those instantiated objects. I can mark those objects somehow, maybe tagging them or adding component with scene index, but it would be nicer if I could know from which bundle objects came from. Is there a way to do so? Or maybe I should use some other approach?
Answer by msknapp · Sep 23, 2011 at 11:58 PM
If I were you then I would write an "AssetBundleManager" class that takes a singleton strategy for managing classes that wrap each asset bundle. The class that wraps each asset bundle can keep a reference to objects instantiated, status of the bundle, etc.
How can the wrapper know what objects are instantiated from bundle? If there were individual assets instantiated I know how it could be achieved, but how to track instantiated assets, that are instantiated while LoadLevelAdditive? The only solution I can think of is to get all gameobjects before and after loading and see what wasn't there before, but it seems to me like some kind of dirty walkaround.
Your answer
![](https://koobas.hobune.stream/wayback/20220612085015im_/https://answers.unity.com/themes/thub/images/avi.jpg)