Open mvaligursky opened 4 years ago
So this isn't super simple. Some asset types have a download option, some don't. Some download a single file (textures), some download multiple files in zips (models). Needs a bit of thought, but in principle, yeah, I agree with you. I've literally done a multi-select in the asset panel before and expected to be able to download all. Actually, in my case, I just wanted multiple separate downloads to kick off.
The lack of a way to download multiple files is at the top of my wish list for the editor so here is my first pass at implementing it.
Select a bunch of assets in your Playcanvas project, copy/paste the downloadSelected.txt code into your dev console and then call the 'downloadSelected()' function in the console.
If the number of selected files is <= 10 then each file is downloaded individually with a 1 second sleep between each attempt to throttle the list, otherwise the blobs for each file are downloaded using fetch(url) and when all are downloaded they are saved to a zip using the JSZip and FileSaver libraries which are pasted in with the attached code.
I am still learning the PCUI framework so I could use some help aligning the text in the list so that there isn't so much space between the checkbox and file name as well as the footer at the bottom. A stretch goal would be to include asset icons and types.
I found an odd issue where using fetch(url) would sometimes give a "net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)" error and the resulting blob was empty. Oddly this does not trigger an error so I found a workaround where I check if the blob.size is valid which throws an undefined error I can catch and retry the download (right now the allowance is for 5 consecutive retries in practice only 2 have been necessary from my testing).
I think with a little more polish this download method could be integrated into the official editor code?
Let me know what you guys think! Happy to make any changes feel free to tear my code apart, I spent the last 6 years in UE4 C++ so my Javascript is rusty!
Just some relevant comments here for current / soon to be released options to do something similar - which might be all is needed for many specific uses:
we've recently released https://github.com/playcanvas/playcanvas-sync which allows two way sync of files between local file system and playcanvas. Not as easy set up as few clicks in Editor, it could be useful for this.
whole project can be exported / archived and downloaded as a zip.
we're in the final testing stages of Copy & Paste functionality, which allows assets to be copied between Playcavas projects. This should be released within few weeks hopefully.
adding @vkalpias for visibility.
Bumping! Was about to write one. Please, allow to download multiple selected assets or a folder. Probably downloaded as a zip archive.
Well, if you do write one, perhaps I can integrate it into the Editor UI codebase. 😄
I meant to say I was about to write one issue about it :D
But yeah, Editor needs an ability to create zip files, for example using https://stuk.github.io/jszip/. Not sure we can do it on the client side without it.
If I select multiple files in Editor's Library, right click and do Download, only one file gets downloaded. Ideally all of them get downloaded (in zip?).