Beispiel #1
0
        public static bool ValidateAndSaveAssetBundle(BundleType bundleType, AssetBundleDownloadTask task)
        {
            string localFilePath = task.AssetBundleInfo.LocalFilePath;

            try
            {
                CreateParentDirectory(localFilePath);
                DeleteFile(localFilePath);
                byte[]          downloadedBytes = task.DownloadedBytes;
                AssetBundleInfo assetBundleInfo = task.AssetBundleInfo;
                if (GlobalVars.DataUseAssetBundle)
                {
                    string str2 = CalculateFileCrc(localFilePath, downloadedBytes);
                    if (str2 != assetBundleInfo.FileCrc)
                    {
                        throw new Exception(string.Format("CRC Mismatch. Local:{0}, Remote:{1}. Retry downloading.", str2, assetBundleInfo.FileCrc));
                    }
                }
                File.WriteAllBytes(localFilePath, downloadedBytes);
                return(true);
            }
            catch (Exception)
            {
                if (File.Exists(localFilePath))
                {
                    File.Delete(localFilePath);
                }
                return(false);
            }
        }
Beispiel #2
0
        public bool AddDownloadTask(AssetBundleDownloadTask downloadTask)
        {
            if (downloadTask == null)
            {
                return(false);
            }
            string remoteFilePath = downloadTask.AssetBundleInfo.RemoteFilePath;

            if (this._downloadTaskDict.ContainsKey(remoteFilePath))
            {
                return(false);
            }
            this._downloadTaskDict.Add(remoteFilePath, downloadTask);
            this._downloadTaskList.Add(downloadTask);
            base.StartCoroutine(downloadTask.StartDownload());
            return(true);
        }