Пример #1
0
 private IEnumerator LoadLocalAssetBundles(RemoteAssetBundleMap assetMap)
 {
     IEnumerator[] tasks = new IEnumerator[assetMap.localAssetBundles.Length];
     for (int i = 0; i < assetMap.localAssetBundles.Length; i++)
     {
         tasks[i] = LoadLocalAssetBundle(assetMap.localAssetBundles[i], assetMap);
     }
     yield return(taskQueue.All(tasks));
 }
Пример #2
0
 private IEnumerator FetchAssetBundle(RemoteAssetBundle bundle, RemoteAssetBundleMap assetMap)
 {
     System.Action <string, AssetBundle> callback = (error, b) =>
     {
         if (!string.IsNullOrEmpty(error))
         {
             Debug.LogError(error);
         }
         else
         {
             if (b)
             {
                 assetMap.AddLoadedRemoteBundle(b);
             }
         }
     };
     return(RemoteAssetBundleUtils.DownloadAssetBundleAsync(remoteAssetBundleEndpoint, bundle, callback));
 }
Пример #3
0
        private IEnumerator LoadLocalAssetBundle(string path, RemoteAssetBundleMap assetMap)
        {
            string absPath       = System.IO.Path.Combine(Application.streamingAssetsPath, path);
            var    bundleRequest = AssetBundle.LoadFromFileAsync(absPath);

            yield return(bundleRequest);

            AssetBundle b = bundleRequest.assetBundle;

            if (b)
            {
                assetMap.AddLoadedLocalBundle(b);
            }
            else
            {
                throw new Exception("Unable to Load Local Asset Bundle");
            }
        }
Пример #4
0
        private IEnumerator FetchAssetBundles(string key)
        {
            RemoteAssetBundleMap assetMap = System.Array.Find(
                remoteAssetBundleMaps,
                (RemoteAssetBundleMap map) => map.assetBundleKey == key
                );

            if (assetMap == null || assetMap.Manifest.bundles == null)
            {
                yield return(null);
            }
            else
            {
                RemoteAssetBundle bundle;
                IEnumerator[]     tasks = new IEnumerator[assetMap.Manifest.bundles.Length];
                for (int i = 0; i < assetMap.Manifest.bundles.Length; i++)
                {
                    bundle   = assetMap.Manifest.bundles[i];
                    tasks[i] = FetchAssetBundle(bundle, assetMap);
                }
                UpdateProgressBar(0.0f, "Preparing To Download Assets");
                CoroutineQueue.HandleProgressUpdate func = PrepareProgress(
                    string.Format("Downloading {0} Assets for {1}",
                                  tasks.Length.ToString(),
                                  assetMap.displayName
                                  ));
                taskQueue.OnProgressUpdate += func;
                yield return(taskQueue.All(tasks));

                taskQueue.OnProgressUpdate -= func;
                if (OnAssetBundlesLoaded != null)
                {
                    OnAssetBundlesLoaded(key);
                }
                UpdateProgressBar(1.0f, "All Assets Downloaded");
            }
        }