But I’d like to be able to browse the existing folders within StreamingAssets. I’m working on a game supporting mods and part of that includes, that users can add content to StreamingAssets and it’s subfolders.
This means that I need some functionality to browse StreamingAssets to see, what files and (sub)folders are present.
On “normal” platforms, I just do something like this:
var filePaths = Directory.GetFiles(Application.streamingAssetsPath, "*", SearchOption.AllDirectories);
foreach (var filePath in filePaths)
{
//do stuff with files
}
But obviously, that doesn’t work in a WebGL project/with a UnityWebRequest object.
A solution wouldn’t necessarily have to be as comfortable as Directory.GetFile(…). I’d be more than happy with using some recursion or whatever. But even for that I would at least need to be able to somehow read the contents of a folder.
Does anyone have any idea if there’s a solution to this?
Thank you very much for your input! A manifest file would certainly work.
I was just hoping for there to maybe be some Unity functionality I didn’t know about that would let me analyze the StreamingAssets folder. But since you’re from Unity, I strongly assume, you’d have told me so if that was the case
If anyone else has another idea, that’s still very welcome of course!
If not, I’ll have to think about whether it’s worth to go the manifest file route or not. Thing is, I’m not targeting WebGL in the end anyway. Having a WebGL build (in my case) is just super convenient to share progress with people that are not directly involved in the project. Just being able to share an URL is a huge plus. No downloading, no extracting, no nothing. Just clicking on a link and you’re good to go.
Using a manifest file would mean that it either has to be written by hand, which isn’t feasible at all, or that I’ll have to write a tool that auto generates the manifest file. And that tool will have to be maintained and expanded throughout the whole project. It’s would be absolutely doable but also sounds like might become more of a hassle than requiring people to download new builds.
So, please just don’t hold it against me if I’m not going down that route in the end
It’s certainly a solution that would work well and I thank you for that. I’m just not sure if it’s worth the effort in my case.
Sorry, I think my post was a bit confusing. What I was trying to say was this: I’m not targeting WebGL in the end but during development it proved to be very convenient to make a WebGL build and upload it to a server whenever I wanted to share progress and get feedback with/from people.
And that’s why I’d like the project to stay WebGL compatible as long as it’s not too much work to do so.