unity-technologies / backgrounddownload Goto Github PK
View Code? Open in Web Editor NEWPlugins for mobile platforms to enable file downloads in background
License: Other
Plugins for mobile platforms to enable file downloads in background
License: Other
This code not working
What is wrong?
List<BackgroundDownloadConfig> configList = GetConfigList();
foreach (var config in configList)
{
BackgroundDownload.Start(config);
}
Can I queue multiple downloads?
foreach (var config in configList)
{
BackgroundDownload.Start(config);
}
EDIT: I mistook 'does not work in Editor, only compiles' to mean that it would still 'compile'/build - given how addressables are built I see now that is not the case
I am trying to get this package to work with addressables by rolling my own ResourceProvider. I have installed it via git url in the package manager.
I am able to successfully build addressables - in Editor - when the platform is set to iOS, but when set to Windows/Standalone, I get the following editor errors:
Script updater for Library\Bee\artifacts\1900b0aP.dag\Assembly-CSharp.dll failed to produce updates.txt file
Assets\_App\Scripts\BackEnd\Managers\BackgroundDownloadManager.cs(2,13): error CS0234: The type or namespace name 'Networking' does not exist in the namespace 'Unity' (are you missing an assembly reference?)
Failed to compile player scripts
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
SBP ErrorError
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
Addressable content build failure (duration : 0:00:06.422)
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
I see that the main issues causing Library\Bee\artifacts
errors to come up include:
The script I am using this in to test incredibly bare-bones, the error does not occur when I comment out any reference to Unity.Networking
and BackgroundDownload
:
using Unity.Networking;
using UnityEngine;
public class BackgroundDownloadManager : MonoBehaviour
{
void Start()
{
var existingDownloads = BackgroundDownload.backgroundDownloads;
}
}
Any help would be much appreciated, thanks.
Hi,
Everything works fine on iOS, but when I close the app and then reopen it again the existing download is failed.
Any workaround for this?
Thanks,
Ivan
Internal build system error. BuildProgram exited with code 87.
System.ArgumentException: Another action is already registered for /ProjectName/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/backgrounddownload.androidlib/build.gradle
New:{
"Annotation": "ActionGenerateProjectFiles /ProjectName/Library/Bee/Android/Prj/IL2CPP/Gradle/build.gradle (+6 others)",
What should I do to use this library?
When pausing and resuming the application, sometimes the download never switches status to Done, despite progress being 1, and the file being fully downloaded.
In Unity 2019.3, because of the manifest changes, when building for Android none of the items in the AndroidManifest are included in the final manifest of the app.
This causes the permissions not to be set correctly and the absence of the completion receiver.
Please take a look at the code below:
using (var download = Unity.Networking.BackgroundDownload.Start(new Uri(URL), Application.persistentDataPath+"/temp/assets"))
{
while (download.progress <=1.0f)
{
percent = download.progress * 100;
DownloadProgressbar.GetComponent<Progressbar>().SetValue((int)percent);
yield return null;
}
yield return new WaitForSeconds(0.5f);
if (download.status == Unity.Networking.BackgroundDownloadStatus.Failed)
{
Debug.Log(download.error);
}
}
it does not give me the progress of my download operation. also I have used
yield return new download
but it doesn't work.
Please help with a proper documentation.
@aurimasc
@Tak
@lucasmeijer
Thanks in advance.
I need a way to concurrently download multiple files - one at a time execution is not feasible. I've been using this repo as a replacement to yours until you support this feature. Am also looking for a way to pause and restart downloads?
Can I use this custom methods? (in BackgroundDownload.cs)
Start(IEnumerable configs)
AvailiableDownloadConfig(BackgroundDownloadConfig config)
public static BackgroundDownload Start(BackgroundDownloadConfig config)
{
LoadDownloads();
if (AvailiableDownloadConfig(config) == false)
return null;
...
}
public static void Start(IEnumerable<BackgroundDownloadConfig> configs)
{
LoadDownloads();
foreach (var config in configs)
{
if (AvailiableDownloadConfig(config) == false)
continue;
var download = new BackgroundDownloadimpl(config);
_downloads.Add(config.filePath, download);
}
SaveDownloads();
}
private static bool AvailiableDownloadConfig(BackgroundDownloadConfig config)
{
if (_downloads.ContainsKey(config.filePath))
{
string error = "Download of this file is already present";
Debug.LogError(error);
return false;
}
return true;
}
Hi,
Can you provide more details on how to access the final downloaded file on iOS please?
I'm able to complete the download but it seems the file isn't actually being copied from the temp directory to the final directory.
I added a boolean value to determine if the replaceItemAtURL operation completes and it returns false.
[code=CSharp] NSFileManager* fileManager;
NSURL* destUri = GetDestinationUri(downloadTask.taskDescription, &fileManager);
[fileManager replaceItemAtURL: destUri withItemAtURL: location backupItemName: nil options: NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL: nil error: nil];
UnityBackgroundDownload* download = [backgroundDownloads objectForKey: downloadTask];
download.status = kStatusDone;[/code]
Hoping someone who's familiar with iOS might have an idea about what is wrong?
I'm using Unity 2019.1.14f.
Thanks,
when we create large number of download(e.g:20000+files),this tool will be severe lagging,is there any solution to solve this condition~,thanks
download.progress does not show a value between 0-1 on devices running Android 9.0 or above. download.progress jumps to 1 instantly, even though the download does actually continue in the background as expected, and will ultimately download successfully. This will cause progress bars based off of the download percentage to fail.
I've tested this on different devices, and it only happens when i seem to use a device running Android 7.0. When the download changes status to Done, then the file is deleted. Before that, i can see that the file is present in the correct destination folder, but as soon as it finishes downloading, the file is gone.
05-20 15:30:22.007 6687 6767 E Unity : AndroidJavaException: java.lang.ClassNotFoundException: com.unity3d.backgrounddownload.BackgroundDownload
05-20 15:30:22.007 6687 6767 E Unity : java.lang.ClassNotFoundException: com.unity3d.backgrounddownload.BackgroundDownload
05-20 15:30:22.007 6687 6767 E Unity : at java.lang.Class.classForName(Native Method)
05-20 15:30:22.007 6687 6767 E Unity : at java.lang.Class.forName(Class.java:453)
05-20 15:30:22.007 6687 6767 E Unity : at java.lang.Class.forName(Class.java:378)
05-20 15:30:22.007 6687 6767 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
05-20 15:30:22.007 6687 6767 E Unity : at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
05-20 15:30:22.007 6687 6767 E Unity : at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source:157)
05-20 15:30:22.007 6687 6767 E Unity : at android.os.Handler.dispatchMessage(Handler.java:105)
05-20 15:30:22.007 6687 6767 E Unity : at android.os.Looper.loop(Looper.java:207)
05-20 15:30:22.007 6687 6767 E Unity : at com.unity3d.player.UnityPlayer$c.run(Unknown Source:20)
05-20 15:30:22.007 6687 6767 E Unity : Caused by: java.lang.ClassNotFoundException: Didn't find class "com.unity3d.backgrounddownload.BackgroundDownload" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.dreamvr.app-teTJPn0kld-PS3kU1p1LSw==/base.apk"],nativeLibraryDirectories=[/data/app/com.dreamvr.app-teTJPn0kld-PS3kU1p1LSw
Hi jcunity,
We tried your backgrounddownload project but does not run properly.
we tried the sinlgefiledownload.cs script but does not download the file in android.
Give any suggestion to run it properly.
Thanks in Advance.
I have 2019.3.9f1, integrated BackgroundDownloader in April'20, tested and everything was smooth on my android test-devices. Now I builded a new version, and the Manifest is not merging anymore.
Those informations may help:
I can't build the project, it says there is a problem with the Gradle.
If I remove the asset, I can build
is it possible to callback download speed per seconds, or downloaded bytes length , in order to show out.
Our app creates high-bandwidth user-generated content we need to upload to our (S3) servers. So I'd love to see a package that also supports uploads. Are you aware of any or see a chance to extend this package for uploads? I looked in the Asset Store, but couldn't find any.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.