Unity 5.2 UnloadUnusedAssets Crash

I just upgraded to Unity 5.2p1 after having the same crash in Unity 5.2 and have now narrowed it down to Resources.UnloadUnusedAssets.

We have a rather complicated Asset loading system where we load lots of assets from Asset Bundles.
When unloading assets we iterate through all the bundles that can be unloaded and call their Unload method. Afterwards we found this had little effect unless Resources.UnloadUnusedAssets was also called. Now calling his method crashes the Editor.

for(int i = 0 ; i < m_UnloadableBundles.Count ; ++i)
{
    string bundleName = m_UnloadableBundles[i];
    bool inUse = m_BundlesInUse.Contains(bundleName);
    bool pending = m_PendingBundles.ContainsKey(bundleName);
    if(pending == false && inUse == false)
    {
        if(m_LoadedBundles.ContainsKey(bundleName) == true)
        {
            if(m_LoadedBundles[bundleName] != null)
            {
                m_LoadedBundles[bundleName].Unload(false);
            }
            m_UnloadableBundles.Remove(bundleName);
            m_LoadedBundles.Remove(bundleName);
        }
    }
}

var op = Resources.UnloadUnusedAssets();
host.WaitForOp(op, (operation) =>
{
    callback.AttemptInvoke();
});

I’m curious, any success on figuring out a fix for this issue?

We encoutered the same issue and we also have a somewhat complicated asset loading system.

Unfortunately no, we just had to roll back, we’re still on Unity 5.1.4f1