Search Unity

File Browser - Native file browser for standalone

Discussion in 'Assets and Asset Store' started by Stefan-Laubenberger, Dec 28, 2017.

  1. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    No, "OpenSingleFile" works without any problems.
     
  2. eggtart

    eggtart

    Joined:
    Feb 4, 2013
    Posts:
    23
    I tried, the file dialog opens but I cannot select any file.

    P.S. After some experimenting, I found I need to put in an extension, e.g. "png", the default "*" does not work.
     
    Last edited: Jun 28, 2019
  3. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hello again

    To select any files, simply call FB like this:
    Code (CSharp):
    1. string path = FileBrowser.OpenSingleFile();
    I hope this helps.


    Cheers
    Stefan
     
  4. eggtart

    eggtart

    Joined:
    Feb 4, 2013
    Posts:
    23
    This is what I did, but I could not select any file.

    I have to specify an extension like this
    string path = FileBrowser.OpenSingleFile("png");
    then I will be able to select the png files
     
  5. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi eggtart

    FB uses the built-in file browser inside the Editor under macOS.
    We assumed that the implementation behaves the same on all platforms, but unfortunately, it's different between Windows and macOS. :(

    However, here is a fix for that - please change the method "getFilter" in "FileBrowser.cs" (starting on line 360):
    Code (CSharp):
    1. private static ExtensionFilter[] getFilter(params string[] extensions)
    2. {
    3.     if (extensions != null && extensions.Length > 0)
    4.     {
    5.         ExtensionFilter[] filter = new ExtensionFilter[extensions.Length];
    6.  
    7.         string extension;
    8.  
    9.         for (int ii = 0; ii < extensions.Length; ii++)
    10.         {
    11.             extension = string.IsNullOrEmpty(extensions[ii]) ? "*" : extensions[ii];
    12.  
    13.             if (extension.Equals("*")) {
    14.                 filter[ii] = new ExtensionFilter(Util.Constants.TEXT_ALL_FILES, Util.Helper.isMacOSEditor ? string.Empty : extension);
    15.             } else
    16.             {
    17.                 filter[ii] = new ExtensionFilter(extension, extension);
    18.             }
    19.        
    20.         }
    21.  
    22.         if (Util.Config.DEBUG)
    23.             Debug.Log("getFilter: " + filter.CTDump());
    24.  
    25.         return filter;
    26.     }
    27.  
    28.     return null;
    29. }
    Please let me know if it works for you.

    Thank you for the report!


    So long,
    Stefan
     
  6. eggtart

    eggtart

    Joined:
    Feb 4, 2013
    Posts:
    23
    It is working perfectly now. Thank you so much for providing this plugin.

    Hope this change will make it to the next update :p
     
    Stefan-Laubenberger likes this.
  7. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Thank you for your feedback!
    Sure thing, the update with the fix will be released during the next week. ;)


    All the best
    Stefan


    P.S: if you want to support us, please write a little review. Or even better, consider buying the PRO version :rolleyes:
     
  8. cricketspike

    cricketspike

    Joined:
    Apr 5, 2017
    Posts:
    8
    Hi with the newest (Pro) version when I build an executable Ive noticed my data folder is much larger, and when I looked inside it, all of my scripts are exposed and put in a folder called FBWrapper.exe, basically my entire asset folder is in there. Is this a bug? Is there a way to turn it off?
     
    Last edited: Jul 3, 2019
  9. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi cricketspike

    Did you follow the upgrade instructions in chapter 6 of the documentation?
    https://www.crosstales.com/media/data/assets/FileBrowser/FileBrowser-doc.pdf

    FB 2019.3.5 has no "FBWrapper.exe" so it seems to be a problem with a previous version.

    Cheers
    Stefan
     
  10. cricketspike

    cricketspike

    Joined:
    Apr 5, 2017
    Posts:
    8
  11. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    97
    Hey there,

    I am trying to use the standalone version of this in 2017.4.29, and while it works in the editor it completely breaks my builds. Having it imported causes my builds to freeze after the splash screens. This is happening on Windows x86 and x86_64 builds.
     
  12. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi

    Are you building with IL2CPP?
    Do you see any entries in the player-log?


    So long,
    Stefan
     
  13. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    97
    I am not building with IL2CPP, and unfortunately the log doesn't have anything useful in it.
     
  14. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    We just did a test with Unity 2017.4 and it runs flawless on our side.

    Can you please create a new, empty project, import FB, add "ExamplesSync" to the build and then build and run it; what happens?
     
  15. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    97
    Well, it seems that the issue has somehow resolved itself. I also learned that while the Windows build was broken, the Mac and Linux builds were working fine. I'm not sure what to make of this but hopefully it won't be a problem anymore. My project is fairly large so who knows what could have been causing it to crash. Heck it could have been just needing to restart Unity.
     
    Stefan-Laubenberger likes this.
  16. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    We've just released version 2019.4.0 of FB.
    Main changes:
    • Updated for Unity 2017.4 and higher
    • Added compatibility with assembly definitions
    • Unity Editor (macOS): all files ("*") is now working correctly
    • Demos: fully qualified access to classes
    • Updated to Common 2019.4.0
     
    AlanMattano likes this.
  17. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    The new versions are in the store!
     
  18. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,044
    Stefan-Laubenberger likes this.
  19. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    You're welcome, I'm happy when our tools are used in a real product!
    Btw, your application looks great, I wish you all the best with it!

    Have a nice weekend!


    Cheers
    Stefan
     
    Last edited: Jul 26, 2019
  20. yinono

    yinono

    Joined:
    Sep 15, 2010
    Posts:
    26
    Hi Stefan,
    Thank you for a great plugin.

    On Linux (debian) the dialogs are opened minimized and sometimes behind the unity application.
    Is there anything I can do to fix that?

    Also, On windows, Open folder open a file selection dialog:


    And not the folder selection dialog:


    Do I do something wrong?

    Thanks
    Yinon
     
  21. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi Yinon

    About Linux: unfortunately, every Linux distro has it's own quirks, so our the possibilities are fairly limited. On top of that, Unity's Linux support isn't that great and it changes all the time :( It works on Ubuntu 18.04 and built with Unity 2017.4.
    Anyway, in the PRO version, we included the whole source, so you're able to test and modify it.

    The folder selector in the free version is indeed a file selector. This is due the used libraries (btw. Unity's own Editor folder browser works the same way).
    Anyway, I can only once more refer to the PRO version. It contains a purely native implementation (no Okii.Dialogs.dll), works with IL2CPP and has the "real"-folder selector.

    I hope this helps you further.


    Cheers
    Stefan
     
  22. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    44
    Hi,

    we bought the Pro Version and added it to our Project. We are using IL2CPP and get a crash in the compiled App when calling `FileBrowser.OpenSingleFile`. Targetplatform is Windows. Have you any tipps for us (we have deleted the prefabs and ui folder).

    Thank you!
     
  23. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    44
    ... The Logfile does not give any hint, even in development mode...
     
  24. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    44
    After checking some other log file, I found:

    ERROR: SymGetSymFromAddr64, GetLastError: 'Es wurde versucht, auf eine unzulässige Adresse zuzugreifen.' (Address: 000B1015)
    0x000B1015 (MY-PROGRAM) (function-name not available)
    ERROR: SymGetSymFromAddr64, GetLastError: 'Es wurde versucht, auf eine unzulässige Adresse zuzugreifen.' (Address: 000B11D9)
    0x000B11D9 (MY-PROGRAM) (function-name not available)

    We are using unity 2019.2.0f1
     
  25. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi Zapan

    We've just tested it with Unity 2019.2.0 and you're unfortunately totally right, FB is crashing with IL2CPP :(

    We have to investigate this, but I suspect that it's because Unity 2019.2.0 is the new version of the 2019.2-line and seems to be buggy as usual with Unity's first release.
    We recommend to use 2019.1.13 (or even better 2018.4.5 (LTS)).

    Anyway, please give us some time to analyze it further.


    So long,
    Stefan
     
  26. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,101
    Testing the free version on 2017 LTS [old I know], Unity windows standalone often errors on closing the FileBrowser dialogue - "An abnormal situation has occurred: the PlayerLopp internal function had been called recursively...".
    This is not unique to this file browser and may be a Unity bug to do with launching native dialogues, but if anyone has seen this issue and fixed it I would like to know!
     
  27. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    44
    @ Stefan-Laubenberger

    Thank you for the Feedback. Before we bought your plugin, we were using the base standardFileBrowser like you are referencing. However, this will also crash under il2cpp conditions. Using 2019.1.13 is currently not possible for us, as we need some of the newer features. Please let us know if you have an update for us and/or if we can help you by finding the issue.
     
  28. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi Andy

    Which Unity version are you exactly using?


    So long,
    Stefan
     
  29. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hello again

    I will take a close look in the next 48h.


    Stay tuned,
    Stefan
     
  30. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,101
    2017.4.29 I have yet to find a minimal recreation though, but it relates to any file browser asset we try in our app.
     
  31. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    44
    Hi, do you have any news for us? :)
     
  32. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi Zapan

    I know it sounds like magic, but since we installed Unity 2019.3.0a11 (alpha) and build with Unity 2019.2.0, IL2CPP simply works...
    Don't ask me why, but it's the way it is ;)

    Can you please try that too?


    So long,
    stefan
     
  33. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    I honestly don't know the reason for it. :(
    Have you tried to create an empty project with only our asset?

    If it still causes the same issues, I recommend the PRO-version, which has a native bridge to Windows and is therefore much better integrated in Unity.
     
  34. chuang4305

    chuang4305

    Joined:
    Nov 20, 2018
    Posts:
    4
    Hi Stefan
    We are having problems where the number of files able to be opened at once is limited by the length of the file names, the file browser method Crosstales.FB.FileBrowser.OpenFiles() is returning a path array length of 0. It’s not showing any error inside the editor.
     
  35. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi

    Are you using the free or pro version?


    So long,
    Stefan
     
  36. chuang4305

    chuang4305

    Joined:
    Nov 20, 2018
    Posts:
    4
    I am using the pro version of the asset

    I am also using unity 2018.4
     
    Last edited: Aug 13, 2019
  37. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Please adjust "FileBrowserWindows.cs" line 22 to a higher value, like 65536 and try it again.
     
  38. chuang4305

    chuang4305

    Joined:
    Nov 20, 2018
    Posts:
    4
    It works thanks for the help
     
    Stefan-Laubenberger likes this.
  39. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Great, you're welcome!
     
  40. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    44
    We have imported your plugin in an empty project with unity.2019.2.0f1 and have also installed the newest Unity alpha (2019.3.0a11).

    We build the project with the ExampleSync.unity as start/only scene.

    Here are the results (Architecture x86):

    .net 4.X, IL2CPP, c++ compiler Configuration= Release:
    * Open Single File: Failed
    * Open Files: Failed
    * Open Single Folder: OK
    * Save File: Failed

    .net Standard 2.0, IL2CPP, c++ compiler Configuration= Release:
    * Open Single File: Failed
    * Open Files: Failed
    * Open Single Folder: OK
    * Save File: Failed

    Mono:
    Works always...

    I have uploaded the compiled version here (net4.x, c++ compiler configuration= Debug): http://user.eachtick.com/weinhold/fileBrowserCrashIL2CPP_2019-08-14.zip (~20 MB)

    Maybe this will help you?
     
    Last edited: Aug 14, 2019
  41. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Ok, thank you for the details, I will look into it.

    Meanwhile, can you please build a 64bit version and try it again?
    I built for 64bit Windows and it worked... :mad:
     
  42. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    44
    Nice! This worked. So, when using X86_64 it is working without any problems. So, maybe we will also use X86_64 mode for the app.

    However, it would be nice to understand what the issue is.

    Maybe you can try to build the project with the newest alpha to see if the Problem still exists?
     
    Stefan-Laubenberger likes this.
  43. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi Zapan

    I will take a look at it, but we used the 64bit versions of the native libs under Windows, this is why you encountered those issues.

    I will inform you, if we find a solution. I'm right now on holiday, so please give me until next week.

    You can also reach me under fb@crosstales, which would be faster ;)


    So long
    Stefan
     
  44. panoramabeats

    panoramabeats

    Joined:
    Dec 6, 2016
    Posts:
    9
    Hi, I'm trying to find away to convert my current scripting to use the File Browser plugin.
    In the code below, imageSet is a texture array.
    The texture files are loaded from a folder in Resources called, "Image Set,"

    Code (CSharp):
    1.                         imageSet = Resources.LoadAll<Texture2D>("Image Set");
    2.                         print("Loaded Textures Folder");
    I'm having trouble figuring out a way to call the folder with a string using FileBrowser.OpenSingleFolder();
     
  45. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi

    What exactly are you trying to achieve? Would you like to load textures from within your project or from an external folder?


    So long,
    Stefan
     
  46. panoramabeats

    panoramabeats

    Joined:
    Dec 6, 2016
    Posts:
    9
    Thank you, Stephan!
    My apologies for the vagueness. Still a novice in coding, at best.
    Specifically, I'm trying to load a folder or selection of images from Mac OS into a texture array.
    In the editor, it loads from files from the Resources folder.
    There is a working build for Android that uses a plug-in, Native Gallery, to select and load from the OS file browser.

    I'm not sure if sharing this even helps, but here is how its code works:
    Code (csharp):
    1.  
    2.    else if (AndroidLoad == true)
    3.         {
    4.             NativeGallery.GetImagesFromGallery((paths) =>
    5.            {
    6.                if (paths != null)
    7.                {
    8.                    imageSet = new Texture[paths.Length];
    9.                    for (int i = 0; i < paths.Length; i++)
    10.                        imageSet[i] = NativeGallery.LoadImageAtPath(paths[i]);
    11.                    i %= imageSet.Length;
    12.                }
    13.            });
    14.             print("Loaded Textures Folder");
    15.         }
    16.  
    I realize that this plug-in has to do with textures and images specifically, but I'm looking for a way to do something similar.
    Basically, I'm trying to adapt the string 'paths', above, to load images from a folder, using FB.
     
  47. plagas36

    plagas36

    Joined:
    Sep 3, 2015
    Posts:
    9
    Hi,
    First of all, thanks for this asset. It's been of great help.

    I have one small problem though.
    This asset work perfectly fine on Windows but as soon as I start to work for MAC (or build for MAC), I have a DllNotFoundException. Did anyone got something like this ?

    DllNotFoundException: FileBrowser
    Crosstales.FB.Wrapper.FileBrowserMac.OpenFoldersAsync (System.String title, System.String directory, System.Boolean multiselect, System.Action`1[T] cb) (at Assets/Plugins/crosstales/FileBrowser/Scripts/Wrapper/FileBrowserMac.cs:71)
     
  48. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hi

    Can you please try the sync-version OpenFolders?
    What happens?


    Cheers
    Stefan
     
  49. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,250
    Hello again

    You could do it like that:
    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. using System.Linq;
    4. using System.IO;
    5. using Crosstales.FB;
    6.  
    7. public class FBLoadTextures : MonoBehaviour
    8. {
    9.     private Texture[] imageSet;
    10.  
    11.     public void Start()
    12.     {
    13.         imageSet = getTexturesFromFolder();
    14.     }
    15.  
    16.     private Texture[] getTexturesFromFolder()
    17.     {
    18.         string path = FileBrowser.OpenSingleFolder();
    19.         List<Texture> textures = new List<Texture>();
    20.  
    21.         if (!string.IsNullOrEmpty(path))
    22.         {
    23.             Texture2D texture;
    24.             byte[] fileData;
    25.  
    26.             //For.NET 4.0 and later
    27.             var files = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".jpg") || s.EndsWith(".png"));
    28.  
    29.             //For earlier versions of .NET
    30.             //var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".jpg") || s.EndsWith(".png"));
    31.  
    32.             foreach (string file in files)
    33.             {
    34.                 fileData = File.ReadAllBytes(file);
    35.                 texture = new Texture2D(2, 2);
    36.                 texture.LoadImage(fileData);
    37.  
    38.                 textures.Add(texture);
    39.             }
    40.         }
    41.  
    42.         return textures.ToArray();
    43.     }
    44. }
    45.  
    I hope this helps you further, please let me know if it works for you.


    So long,
    Stefan
     
    panoramabeats likes this.
  50. Bad_Erik

    Bad_Erik

    Joined:
    Jul 15, 2018
    Posts:
    1
    Does this work on IOS? I don't see anywhere in the documentation that highlights this.