Example #1
0
        /// <summary>
        /// 加入缓存 Caches the new one.
        /// </summary>
        /// <param name="assetBundleLoader">Asset bundle loader.</param>
        void CacheNewOne(AssetBundleLoader assetBundleLoader)
        {
            //检测缓存
            AssetBundleInstance assetBundleInstance;

            cache.TryGetValue(curAssetBundleLoader.name, out assetBundleInstance);
            if (assetBundleInstance == null)
            {
                assetBundleInstance             = new AssetBundleInstance();
                assetBundleInstance.name        = assetBundleLoader.name;
                assetBundleInstance.assetBundle = curAssetBundleLoader.assetBundle;
                assetBundleInstance.SetReferenceCount(curAssetBundleLoader.referenceount);
                //添加到缓存
                cache.Add(curAssetBundleLoader.name, assetBundleInstance);
            }
            else
            {
                Debug.LogErrorFormat("{0} 重复加载!", assetBundleInstance);
            }
        }
Example #2
0
 /// <summary>
 /// 执行下一个加载任务
 /// </summary>
 void Next()
 {
     //检测队列
     if (curAssetBundleLoader == null && waiting.Count > 0)
     {
         //弹出排队目标
         curAssetBundleLoader = waiting.Dequeue();
         //检测缓存
         AssetBundleInstance assetBundleInstance;
         cache.TryGetValue(curAssetBundleLoader.name, out assetBundleInstance);
         if (assetBundleInstance != null)
         {
             curAssetBundleLoader.onLoadAssetBundle(curAssetBundleLoader.name, assetBundleInstance.assetBundle);
             curAssetBundleLoader = null;
             return;
         }
         else
         {
             //启动加载
             StartCoroutine(curAssetBundleLoader.LoadAsync(curAssetBundleLoader.name));
         }
     }
 }