Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Fetching DLC download progress in Unity

maverick89atworkmaverick89atwork Posts: 4 Oculus Start Member
edited March 8 in Unity Development
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);
                }
            }
        }
    });
});

Comments

  • maverick89atworkmaverick89atwork Posts: 4 Oculus Start Member
    edited March 12
    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");
                                            }
                                        });


Sign In or Register to comment.