Ejemplo 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);
 }
Ejemplo n.º 2
0
 private void InitDic()
 {
     if (m_dic == null)
     {
         m_dic = new Dictionary <string, string>();
     }
     else
     {
         m_dic.Clear();
     }
     if (replaceData != null)
     {
         for (int dataIndex = 0; dataIndex < replaceData.datas.Count; dataIndex++)
         {
             ReplaceDataItem data = replaceData.datas[dataIndex];
             for (int i = 0; i < data.list.Count; i++)
             {
                 if (data.source == null)
                 {
                     CommonUtils.AddToDictionary(m_dic, data.list[i].replaceKey, data.list[i].replaceValue);
                 }
                 else
                 {
                     CommonUtils.AddToDictionary(m_dic, data.list[i].replaceKey, data.source.GetContent(data.list[i].replaceValue, m_localKey));
                 }
             }
         }
     }
 }
 internal override bool Update()
 {
     if (waitingBundleNames.Count > 0)
     {
         for (int i = waitingBundleNames.Count - 1; i >= 0; i--)
         {
             //每帧获取loadedBundle,等待返回或者出现错误
             LoadedAssetBundle loadedBundle = AssetBundleLoader.GetLoadedAssetBundle(waitingBundleNames[i], out m_Error);
             if (isError)
             {
                 break;
             }
             if (loadedBundle != null)
             {
                 CommonUtils.AddToDictionary(m_AssetBundles, waitingBundleNames[i], loadedBundle.assetBundle);
                 waitingBundleNames.RemoveAt(i);
             }
         }
     }
     return(!isDone);
 }
Ejemplo n.º 4
0
        //下载AssetBundle
        private static void DownLoadAssetBundle(string assetBundleName, bool withDependencies = true)
        {
            //如果assetbundle已经加载完成,则无视操作
            if (GetLoadedAssetBundle(assetBundleName) != null)
            {
                return;
            }
            RequestDownload(assetBundleName);

            //如果需要加载依赖
            if (withDependencies)
            {
                string[] dependencies = assetBundleManifest.GetAllDependencies(assetBundleName);
                if (dependencies != null && dependencies.Length > 0)
                {
                    //如果有依赖则将依赖加入字典中
                    CommonUtils.AddToDictionary(m_Dependencies, assetBundleName, dependencies);
                    foreach (string dependence in dependencies)
                    {
                        RequestDownload(dependence);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void AddRule(string key, string value)
 {
     CommonUtils.AddToDictionary(m_activeDic, key, value);
 }