Beispiel #1
0
        /// <summary>
        ///   下载
        /// </summary>
        bool Download(string assetbundlename)
        {
            lock (lock_obj_)
            {
                var ab = resources_manifest_.Find(assetbundlename);
                if (ab == null)
                {
                    Debug.LogWarning("AssetBundleDownloader.Download - AssetBundleName is invalid.");
                    return(true);
                }

                string file_name = ab.IsCompress ?
                                   Compress.GetCompressFileName(assetbundlename) : assetbundlename;
                if (!IsDownLoading(file_name))
                {
                    HttpAsyDownload d = GetIdleDownload(true);
                    if (d == null)
                    {
                        return(false);
                    }

                    d.Start(Root, file_name, _DownloadNotify, _DownloadError);
                }

                return(true);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 初始化下载信息
        /// </summary>
        void InitializeDownload(string root
                                , List <string> assetbundles
                                , ResourcesManifest resources_manifest)
        {
            Root = root;
            ImcompleteDownloads = assetbundles;
            resources_manifest_ = resources_manifest;

            IsDone    = false;
            ErrorCode = emErrorCode.None;
            CompleteDownloads.Clear();
            FailedDownloads.Clear();

            if (ImcompleteDownloads == null)
            {
                ImcompleteDownloads = new List <string>();
            }

            //统计数据
            TotalSize     = 0;
            CompletedSize = 0;
            for (int i = 0; i < ImcompleteDownloads.Count; ++i)
            {
                var ab = resources_manifest_.Find(ImcompleteDownloads[i]);
                if (ab != null)
                {
                    if (ab.IsCompress)
                    {
                        TotalSize += ab.CompressSize;
                    }
                    else
                    {
                        TotalSize += ab.Size;
                    }
                }
            }
        }