/// <summary>
 /// 资源回收(卸载引用计数为零的资源)
 /// </summary>
 public static void UnloadUnusedAssets()
 {
     if (_simulationOnEditor)
     {
         for (int i = _providers.Count - 1; i >= 0; i--)
         {
             if (_providers[i].CanDestroy())
             {
                 _providers[i].Destroy();
                 _providers.RemoveAt(i);
             }
         }
     }
     else
     {
         for (int i = _loaders.Count - 1; i >= 0; i--)
         {
             AssetBundleLoaderBase loader = _loaders[i];
             loader.TryDestroyAllProviders();
         }
         for (int i = _loaders.Count - 1; i >= 0; i--)
         {
             AssetBundleLoaderBase loader = _loaders[i];
             if (loader.CanDestroy())
             {
                 loader.Destroy(false);
                 _loaders.RemoveAt(i);
             }
         }
     }
 }
        internal static List <AssetBundleLoaderBase> CreateDependAssetBundleLoaders(AssetInfo assetInfo)
        {
            BundleInfo[] depends = BundleServices.GetAllDependBundleInfos(assetInfo);
            List <AssetBundleLoaderBase> result = new List <AssetBundleLoaderBase>(depends.Length);

            foreach (var bundleInfo in depends)
            {
                AssetBundleLoaderBase dependLoader = CreateAssetBundleLoaderInternal(bundleInfo);
                result.Add(dependLoader);
            }
            return(result);
        }
        private static AssetBundleLoaderBase TryGetAssetBundleLoader(string bundleName)
        {
            AssetBundleLoaderBase loader = null;

            for (int i = 0; i < _loaders.Count; i++)
            {
                AssetBundleLoaderBase temp = _loaders[i];
                if (temp.MainBundleInfo.BundleName.Equals(bundleName))
                {
                    loader = temp;
                    break;
                }
            }
            return(loader);
        }
        private static AssetBundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
        {
            // 如果加载器已经存在
            AssetBundleLoaderBase loader = TryGetAssetBundleLoader(bundleInfo.BundleName);

            if (loader != null)
            {
                return(loader);
            }

            // 新增下载需求
#if UNITY_WEBGL
            loader = new AssetBundleWebLoader(bundleInfo);
#else
            loader = new AssetBundleFileLoader(bundleInfo);
#endif

            _loaders.Add(loader);
            return(loader);
        }