Example #1
0
        private async void UnityBackgroundDownloadStart(IntPtr www, string full_path)
        {
            BackgroundDownloadConfig config = new BackgroundDownloadConfig();

            config.url      = www.uri;
            config.filePath = full_path;
            var dl = new BackgroundDownloadEditor(www, config);

            try {
                _dwnloads.Remove(full_path);
            }
            catch (Exception) {
            }
            _dwnloads.Add(full_path, www);
            if (!full_path.Contains(Application.persistentDataPath))
            {
                full_path = System.IO.Path.Combine(Application.persistentDataPath, full_path);
            }
            _status = BackgroundDownloadStatus.Downloading;
            await www.SendWebRequest();

//            _status = www.isDone ? BackgroundDownloadStatus.Done : www.isHttpError? BackgroundDownloadStatus.Failed : BackgroundDownloadStatus.Downloading;
            //            _dwnloads.Remove(full_path);

/*
 *          BinaryWriter writer = new BinaryWriter(File.OpenWrite(full_path));
 *          writer.Write(www.downloadHandler.data, 0, www.downloadHandler.data.Length);
 *          writer.Flush();
 *          writer.Close();
 */
        }
Example #2
0
        internal static Dictionary <string, BackgroundDownload> LoadDownloads()
        {
            Dictionary <string, BackgroundDownload> downloads = new Dictionary <string, BackgroundDownload>();

            foreach (var item in _dwnloads)
            {
                IntPtr backend = item.Value;
                BackgroundDownloadConfig config = new BackgroundDownloadConfig();
                config.url      = backend.uri;
                config.filePath = item.Key;
                var dl = new BackgroundDownloadEditor(backend, config);
                downloads[config.filePath] = dl;
            }
            return(downloads);
        }