Skip to main content
March 8, 2019

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.

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);
}
}
}
});
});
This topic has been closed for replies.

4 replies

March 12, 2019
Doing 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");
}
});


LuisZan
Inspiring
June 13, 2021

Thanks for the solution.

 

One question: Should I add your code sample inside the body of DownloadById's OnComplete function or somewhere else?

Inspiring
June 12, 2019
Thanks @maverick89atwork! Very helpful