- Home /
OpenFilePanel alternative
Hello, I am in need of opening a file from the explorer in my Unity project.
The code I use now is the following:
string newFilePath = EditorUtility.OpenFilePanel("Select JSON file", Application.streamingAssetsPath, "json");
//Debug.Log ("Game is loaded with this level: " + newFilePath);
if (newFilePath.Length != 0) {
JSONLines = "";
filePath = newFilePath;
StreamReader reader = new StreamReader(filePath);
while ((line = reader.ReadLine()) != null)
{
JSONLines += line;
}
This obviously does not translate to a standalone build because it is EditorUtility.
Is there a way to make this happen in a standalone build (let the user select a JSON file and return the content as a string)?
PS: I have looked at the UniFileBrowser offered by user Eric but if it is not too much of a hassle I would rather have it non-paying.
PS2: I took a look at this http://wiki.unity3d.com/index.php?title=ImprovedFileBrowser but I am completely lost in how to get this working (if it even can do what I want).
Thanks a lot for the help in advance, Dennis
We seriously need an answer to this... Is there no way? I've been searching for hours
This one from the assert store doesn't look very nice, but it works: https://www.assetstore.unity3d.com/en/#!/content/18308
The ImprovedFileBrowser from the link above needs some work. Displaying the files works, but you can't select any file.
The options are: buy a paid asset with support, create your own, or try to make do with free stuff. There isn't any built-in run-time equivalent of OpenFilePanel.
Answer by gkngkc · Jan 11, 2017 at 09:00 AM
I wrote similar thing for one of my projects.
You're a life savior @gkngkc !!!! This was exactly what i was trying to find for weeks! Really amazing
It works fine when building in Editor but using Cloud build, it will fail to find the Drawing.dll.
Hmm, i used it in a cloud build project and worked fine for me. Not sure what causing this. Usually Drawing.dll error caused by API Compatibility Level selection.
I posted else where and someone had a similar issue, not related to your plugin but to missing Drawing.dll in cloud build. Not sure then as you seem to have it running.