Search Unity

Question How do you clear a scene and keep your assetbundles from unloading?

Discussion in 'Asset Bundles' started by dansav, Nov 7, 2022.

  1. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    I'm using WebGL and my loaded assetBundle becomes null after I Load a new scene. I want it to reload the scene to clear it as suggested in this thread
    https://forum.unity.com/threads/any-way-to-reset-the-scene.23986/
    but keep my assetbundles so I can instantiate objects from them, but when I load the scene to clear the project the assetbundles are unloaded.

    In the console.log I get these lines when clearing and loading a new scene.
    Unloading 5 Unused Serialized files (Serialized files now loaded: 1)
    Unloading 255 unused Assets to reduce memory usage.
    And when I try to instantiate something from the previously loaded assetbundle the assetbundle is now null.

    using LoadSceneMode.Additive will not clear the scene -- I don't want to load the same scene over an existing scene because that will duplicate scene items.

    Is there a way to clear a scene by reloading it and keep the asset bundle that you already loaded?