private void UnLoadAssetBundle(string abName) { AssetBundleItem item = null; uint crc = CRC32.GetCRC32(abName); if (m_AssetBundleItemDic.TryGetValue(crc, out item) || item != null) { item.RefCount--; if (item.RefCount <= 0 && item.assetBundle != null) { item.assetBundle.Unload(true); item.Rest(); m_AssetBundleItemPool.Recycle(item); m_AssetBundleItemDic.Remove(crc); } } }
/// <summary> /// 卸载 AB /// </summary> /// <param name="name"></param> private void UnLoadAssetBundle(string name) { AssetBundleItem item = null; uint crc = CRC32.GetCRC32(name); if (assetBundleItemDic.TryGetValue(crc, out item) && item != null) { item.RefCount--; if (item.RefCount <= 0 && item.assetBundle != null) // 确保没有被引用了 { item.assetBundle.Unload(true); // 卸载 item.Rest(); // 还原 类对象池 assetBundleItemPool.Recycle(item); assetBundleItemDic.Remove(crc); } } }
/// <summary> /// 根据ab包名卸载ab包 /// </summary> /// <param name="abName"></param> public void UnLoadAssetBundle(string abName) { uint crc = Crc.GetCRC32(abName); AssetBundleItem item = null; if (m_AssetBundleItemDic.TryGetValue(crc, out item) || item != null) { item.refCount--; if (item.refCount <= 0 && item.assetBundle != null) { Debug.Log(abName); //没有引用 item.assetBundle.Unload(true); item.Rest(); m_AssetBundleItemPool.Recycle(item); m_AssetBundleItemDic.Remove(crc); } } }