Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

AssetBundle.UnloadAllAssetBundles() doesn't unload scene bundles

Discussion in 'Asset Bundles' started by PW_Dave, Jan 17, 2019.

  1. PW_Dave

    PW_Dave

    Joined:
    Feb 9, 2017
    Posts:
    30
    I've been doing some testing of the AssetBundle system in order to formulate a plan to support variants with our asset management system. I have a custom editor that exposes most of the raw functionality of the AssetBundle system and I've discovered that AssetBundle.UnloadAllAssetBundles() does not unload scene bundles. Which is kind of annoying.

    My custom editor works fine when I use it to load/unload bundles and I can keep track of everything. But when I open the window during a play session or after closing/recompiling, any scene bundles that are loaded are effectively inaccessible. Due to the following issue (where AssetBundle.GetAllLoadedAssetBundles() doesn't return scene bundles): https://forum.unity.com/threads/ass...etbundles-not-returning-scene-bundles.503657/ , I can't get a reference to the loaded scene bundle. It's basically orphaned and stuck in memory. I have to restart Unity to fix it.

    I'm using Unity 2018.2, in case it's been fixed since then.
     
    unity_QzmvR2WrBsSXAw likes this.
  2. PW_Dave

    PW_Dave

    Joined:
    Feb 9, 2017
    Posts:
    30
    After further work, it turns out that I just need to enter/exit play mode to workaround this issue. Apparently, exiting play mode unloads all bundles including scene bundles. Still, it would be nice to have this fixed.
     
  3. R0hit97

    R0hit97

    Joined:
    Feb 15, 2018
    Posts:
    2
    Found any solution for this issue ? I am facing the same problem.
     
  4. PW_Dave

    PW_Dave

    Joined:
    Feb 9, 2017
    Posts:
    30
    We are still using the same version of Unity (2018.2.15f1) as we were when I made this post, so I don't know if it's been fixed. I ended up entering/exiting play mode whenever I needed to make sure everything was flushed. We are going to upgrade to 2018.4 next week, so perhaps it has been fixed by then? I think that you may be able to use a ScriptableObject to maintain a list of loaded bundles and it would persist beyond refreshes and compilations? I'm not sure about that though.