Exemple #1
0
        // open file stream (file must be listed in manifest)
        private void OpenBundle(UBundle bundle)
        {
            var filename = bundle.name;

            if (LoadBundleFile(bundle, _localPathRoot))
            {
                return;
            }
            if (_streamingAssets != null && _streamingAssets.Contains(bundle.name, bundle.checksum, bundle.size))
            {
                bundle.AddRef();
                JobScheduler.DispatchCoroutine(
                    _streamingAssets.LoadBundle(bundle.name, stream =>
                {
                    if (stream != null)
                    {
                        bundle.Load(stream);
                    }
                    else
                    {
                        PrintLog($"read from streamingassets failed: {bundle.name}");
                        DownloadBundleFile(bundle);
                    }
                    bundle.RemoveRef();
                })
                    );
                return;
            }
            DownloadBundleFile(bundle);
        }
        // open file stream (file must be listed in manifest)
        private void OpenBundle(UBundle bundle)
        {
            var filename = bundle.name;

            if (LoadBundleFile(bundle, _localPathRoot))
            {
                return;
            }
            // 无法打开现有文件, 下载新文件
            bundle.AddRef();
            AddDownloadTask(DownloadTask.Create(
                                bundle.name, bundle.checksum, bundle.size, bundle.priority,
                                _urls,
                                _localPathRoot,
                                -1,
                                10,
                                self =>
            {
                _tasks.Remove(self);
                _runningTasks--;
                Schedule();
                if (!LoadBundleFile(bundle, _localPathRoot))
                {
                    bundle.Load(null);
                }
                bundle.RemoveRef();
            }));
        }
Exemple #3
0
 private void DownloadBundleFile(UBundle bundle)
 {
     // 无法打开现有文件, 下载新文件
     bundle.AddRef();
     AddDownloadTask(DownloadTask.Create(bundle.bundleInfo, _urls, _localPathRoot, -1, 10, self =>
     {
         RemoveDownloadTask(self);
         if (!LoadBundleFile(bundle, _localPathRoot))
         {
             bundle.Load(null);
         }
         bundle.RemoveRef();
     }), true);
 }
Exemple #4
0
 // 添加依赖资源包
 public bool AddDependency(UBundle bundle)
 {
     if (bundle != this)
     {
         if (_denpendencies == null)
         {
             _denpendencies = new List <UBundle>();
         }
         else
         {
             if (_denpendencies.Contains(bundle))
             {
                 return(false);
             }
         }
         bundle.AddRef();
         _denpendencies.Add(bundle);
         bundle.completed += OnDependedBundleLoaded;
         return(true);
     }
     return(false);
 }