Exemplo n.º 1
0
 //完成读取或的操作
 private void DownloadFinishOperation(AssetBundleDownLoadOperation operation)
 {
     if (!operation.isError)
     {
         //将下载完成的assetbundle存放在字典里
         LoadedAssetBundle loadedAssetBundle = new LoadedAssetBundle(operation.assetBundleName, operation.assetBundle);
         LoadedAssetBundle testLoadedBundle;
         if (m_LoadedAssetBundles.TryGetValue(operation.assetBundleName, out testLoadedBundle))
         {
             m_LoadedAssetBundles.Remove(operation.assetBundleName);
             testLoadedBundle.UnLoad();
         }
         m_LoadedAssetBundles.Add(operation.assetBundleName, loadedAssetBundle);
         m_DownloadErrors.Remove(operation.assetBundleName);
         //设置dependenciesCount
         SetFinishOperationDependencies(loadedAssetBundle);
     }
     else
     {
         string err = string.Format("'{0}' 下载失败:{1}", operation.assetBundleName, operation.error);
         //将错误信息记录下来
         CommonUtils.AddToDictionary(m_DownloadErrors, operation.assetBundleName, err);
         Debug.LogError(err);
     }
     //移除正在下载的状态
     m_DownloadingBundles.Remove(operation.assetBundleName);
 }
Exemplo n.º 2
0
        //更新下载状况
        private void UpdateDownloadings()
        {
            if (m_DownloadingOperations != null)
            {
                for (int i = m_DownloadingOperations.Count - 1; i >= 0; i--)
                {
                    AssetBundleDownLoadOperation operation = m_DownloadingOperations[i];
                    if (!operation.Update())
                    {
                        //从队列中移除
                        m_DownloadingOperations.RemoveAt(i);
                        //增加完成的progress
                        m_FinishedProgress++;

                        DownloadFinishOperation(operation);
                    }
                }
            }
        }