Ok, so my game is in testing phase and the download system works in the Engine (ue 4.26.2) like this:
First of all you’re gonna’ need a plugin that is eventually Runtime Files Downloader in Code Plugins - UE Marketplace (unrealengine.com)
After that you’re done with all the assets need from anywhere, lets proceed!
You’ll need to do a bit of work in this one. Gather all of the files that are to be downloaded optionally from the menu in game.
Make a folder named “After_Patch” for example, now make subfolders for each set of meshes and their respective texture and material files.
Now, go to each subfolders and add a “Primary Asset Label” one in each subfolders.
For adding primary asset labels right click and go to Blueprints
Then search for Primary Asset Label in BP classes.
In all of them set priority to “1”, Chunk ID to “1001” and increment it by 1 for other assets like “1002”, “1003”, “1004”, and etc. Set cook rule to “Always Cook” and Label Assets in My directory to “true”. Do all the things same
Note: if you have a sound file it will not be automatically referenced by the asset label for that you’ll have to add it in the Explicit assets, same for any blueprint file.
After that for confirming the procedure right click on the asset label and go to “Reference Viewer”
Now If you have done that for all then export your game and make sure your “After Patch” folder is not added into directories to never cook section and Create cooked packages should be false in the packaging section.
Export your Package for Desired platform (if doing for android then make sure to set package game data inside apk to false) and now you will receive some extra pak files with the chunk IDs that were 1001, 1002… appended in the extra pak file’s names. In my case it is
The Step 1 is complete
This step is about uploading the files to server to download them later via game menu.
I used onedrive if you have another way you can use that and skip to step 3.
upload all files to onedrive and you’ll get a link like “-www.dropbox.com/s/eagfsvphrjh6fvb/pakchunk1001-Android_Multi.pak?dl=0”
you just have to change the “dl=0” to “dl=1” and now this link is converted to direct download when requested by game.
Make a list of all the links along with their pak file’s names if there are much of it and then just make some button in the menu.
In the button, first we’ll check that if the pak file is already downloaded in the device memory before if so we’ll not trigger the download event.
} for that do the following:
get project content directory → append with “paks/your_pak’s_name.pak” → query to branch with “File Exists” boolean.
And if true, for now connect a “Print string” that says file exists already
Else if false, then trigger the following events:
Download file to storage and connect url to URL and your pakchunk directory to Save Path and write “application/octet-stream” in Content type
On Progress: this is a delegate pin create a custom event from it and now do this to get percent
try truncating the integer value to return download progress without decimal and further divide it by 100 before ceiling the value if to be used in progress bar element.
On Complete: this is a delegate pin create a custom event from it, it will return if the download failed succeeded or other reasons of download ending.
And you can make different messages like this
Now, we’re done but still before distributing the app lets finalize this system.
go to Project settings and go to Packaging and select create compressed packages and the go to Directories to never cook and add the “After Patch” there. If packaging for android go to android and set package game data inside apk to true if wanted. and we’re done for this. Enjoy
This downloads the file but does not unpack it automatically, If player restarts the game after installing files then the engine recognized the pack files and unpack it. But you can use paid plugins for unpacking after download, you can use the path you used for check if file is available (see Step 3 first image for reference).