Forum Discussion
maverick89atwor
6 years agoExplorer
Fetching DLC download progress in Unity
Hi all,
I am trying to implement DLC download in Unity. These are my environment details: Unity: 2018.3.6f1, Oculus Integration 1.35.
I am able to get the list of DLC files that I've uploaded and also able to download them. However, I am not sure how to get the progress of the download. The documentation suggests subscribing to notifications. https://developer.oculus.com/documentation/platform/latest/concepts/dg-dlc/
Can anyone please share some sample code on how this can be done? I'll share what I have so far below.
I am trying to implement DLC download in Unity. These are my environment details: Unity: 2018.3.6f1, Oculus Integration 1.35.
I am able to get the list of DLC files that I've uploaded and also able to download them. However, I am not sure how to get the progress of the download. The documentation suggests subscribing to notifications. https://developer.oculus.com/documentation/platform/latest/concepts/dg-dlc/
Can anyone please share some sample code on how this can be done? I'll share what I have so far below.
Core.AsyncInitialize().OnComplete((Message InitMsg) =>
{
AssetFile.GetList().OnComplete((Message msg) =>
{
if (msg.IsError)
{
Debug.LogError("Error fetching DLC List: " + msg.GetError().Message);
}
else
{
var assetList = msg.GetAssetDetailsList();
foreach (var item in assetList)
{
Debug.Log("AssetID: " + item.AssetId);
Debug.Log("AssetType: " + item.AssetType);
Debug.Log("DownloadStatus: " + item.DownloadStatus);
Debug.Log("Filepath: " + item.Filepath);
//Download it
if (string.Equals(item.DownloadStatus, "available"))
{
AssetFile.DownloadById(item.AssetId).OnComplete((msg1) =>
{
if (msg1.IsError)
{
Debug.Log("Error downloading assetID: " + item.AssetId + " " + msg1.GetError().Message);
}
else
{
Debug.Log("Downloaded intiated at: " + msg1.GetAssetFileDownloadResult().Filepath);
var r = msg1.GetAssetFileDownloadUpdate();
}
});
}
else
{
Debug.Log("--------------------------------Asset ID: " + item.AssetId + " Status: " + item.DownloadStatus);
}
}
}
});
});
4 Replies
Replies have been turned off for this discussion
- maverick89atworExplorerDoing this worked for me:
Callback.SetNotificationCallback(Message.MessageType.Notification_AssetFile_DownloadUpdate, (Message<AssetFileDownloadUpdate> updateMsg) => {
AssetFileDownloadUpdate downloadUpdate = updateMsg.GetAssetFileDownloadUpdate();
if (downloadUpdate != null)
{
Debug.Log("UpdateStatus: " + downloadUpdate.AssetId + " : " + downloadUpdate.BytesTransferred + " / " + downloadUpdate.BytesTotal);
}
else
{
Debug.Log("Download Update is null");
}
});- Luis.ZanProtege
Thanks for the solution.
One question: Should I add your code sample inside the body of DownloadById's OnComplete function or somewhere else?
- npsoftwareHonored Guest
Hi!
I am not that familiar with Unity and Callbacks.I need to download the files, but I do not want to trigger 70 downloads at a time. So I made a loop and I am checking the status of the first file needed to download. (By asking for the list..)
What I can see is, that the download is triggered 2x as even after 10 seconds, the GetAssetDetailsList() returns the status as "available" instead of "in-progress" in the third run, the file is downloaded and the status is then finished. My logic takes the next file in the list..
Is it possible to trigger the download of the file and have some sort of event when finished, this would trigger another file to be downloaded..
The snippet with the Callback does not work for me, as I do not know, where to place it correctly and what to include where.. Please advice. thanks
- Florian.BRINKProtegeThanks @maverick89atwork! Very helpful
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 6 months ago
- 9 months ago
- 1 year ago