Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Native File Browser - Use native File Browser on Mac and Windows!

Discussion in 'Assets and Asset Store' started by PygmyMonkey, Jul 26, 2016.

  1. puhanda

    puhanda

    Joined:
    Jul 4, 2018
    Posts:
    7
    I tested Mono, it is OK, but I need il2cpp to build project, please help me look what happed.
     
  2. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    I just tried building with IL2CPP on Windows, and everything works fine.
    I tested the build you attached and it crashed 2 times (after delivering the results though), and after that it worked okay without a crash.

    Can you send me (via Private Message) your Unity project so I can take a look?
    Also, more info on the Unity version you're using, the OS etc...

    Thanks.
     
  3. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    NativeFileBrowser 1.0.8 is now available on the Asset Store!
    • NEW: Compatible with Unity 2017 and Unity 2018,
    • NEW: Removed the use of a .exe file for Windows, everything is now under a single DLL,
    • NEW: Added support for 32/64 bits for both Windows/OSX. There is a FileBrowserConfigurator script that will configure the DLLs (Windows) and bundles (OS X) to the correct Platform Settings. So when you build for Windows 64 bits, only the 64 bits version of the DLL will be included in your build,
    • NEW: Added more demos to show multiple uses of the file browser,
    • UPDATE: Removed the use of the NativeFileBrowserDispatcher that is now useless.
     
  4. puhanda

    puhanda

    Joined:
    Jul 4, 2018
    Posts:
    7
    I started a conversation with you. Did you see that? I sended my demo project in that conversation and my pc system info.
     
  5. alxdncn

    alxdncn

    Joined:
    Jun 17, 2016
    Posts:
    3
    Hello, I've been using this plugin for the last couple months, and it's been mostly great. I have, however, been experiencing some crashes and I wanted to see if you could help me with it. It happens intermittently when I press a Unity button that opens the file browser to the Streaming Assets folder. Every once in a while (it was once every 50 times, but seems to be happening more frequently of late), this causes an error. Unity does not crash, just hangs, while my File Explorer (across my system) becomes unusable, including Task Manager.

    Any thoughts? Please let me know if you have any questions or need clarification. I'm on Windows 10 Home version 1803.
     
  6. g-augview

    g-augview

    Joined:
    Mar 28, 2017
    Posts:
    13
    hi
    does your asset support .Net 4.x rntime version with API compatibility level .Net standard 2.0?
     
  7. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello and thanks! Try updating to the latest version (1.0.8) which does not rely on StreamingAssets and an exe file anymore, this should fix your issues :)
     
  8. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello, yes it should (but does not support .Net 2.0 subset) :)

    EDIT: It now supports .Net 2.0 subset (starting from version 2.0.0)
     
    Last edited: Jul 30, 2019
  9. g-augview

    g-augview

    Joined:
    Mar 28, 2017
    Posts:
    13
    Actually it doesn't. It is using windows forms which aren't part of .Net standard 2.0. You might have misread my question, I was not asking about .Net 2.0 but .Net Standard 2.0 (which is using .Net 4.x)... so confusing.
    Any suggestion?
     
  10. irreverentQ

    irreverentQ

    Joined:
    Mar 26, 2013
    Posts:
    2
    Hello! I'm running into an error when trying to build for Windows while on my Mac. When I switch my target platform to Windows, I get 4 compile errors in FileBrowserWindows.cs that all read "The name `Internal' does not exist in the current context". Is there any workaround for this? Thanks much!
     
    jamestrue likes this.
  11. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    Yes, it's a known issue. I still haven't found a way around that...
    In the meantime, if you want to go back to the old versions, send me a private message and I'll give you the link to the old version.

    Have a nice day!
     
  12. irreverentQ

    irreverentQ

    Joined:
    Mar 26, 2013
    Posts:
    2
    Ah that's unfortunate. I guess I'll stay with the current version and use UNITY_EDITOR to manually specify which file to use depending on the OS. Thanks for the response though!
     
  13. Cybernetic_Nick

    Cybernetic_Nick

    Joined:
    Nov 1, 2018
    Posts:
    4
    Does this asset now support full-screen applications? Meaning if the File Browser is called to appear within either Windows or Mac will it pop up over the Unity application that's in full-screen mode, so that the Unity application remains in full-screen mode while the File Browser is shown.

    If that's possible, I'd also like to know how difficult it would be to add "Drag and Drop" functionality where I can drag a file, or multiple files, (even folders) from the File Browser into the full-screen Unity application.
     
  14. Cybernetic_Nick

    Cybernetic_Nick

    Joined:
    Nov 1, 2018
    Posts:
    4
    This successfully got the full screen experience working, so that the Unity application never disappeared when the File Browser was called upon.
     
    PygmyMonkey likes this.
  15. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,136
    This asset seems to have a number of issues now in windows & Unity 2018.2
    You have to set scripting runtime to .net 4.x
    You get a warning about winforms on building to standalone
    You can no longer pass null to FileBrowser.SaveFilePanel for the starting directory
     
    Last edited: Jan 31, 2019
  16. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    There shouldn't be issues like that.
    Can you send me an email so I can send you the latest version?
    contact at pygmymonkey dot com

    Thanks!
     
  17. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,136
    I have sent the info but as yet it is still a little buggy as mentioned
     
  18. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    Re. "name 'internal` does not exist" errors...

    Is there still no solution for this? I've just run into it today and it's holding up a planned release...
     
  19. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    I just sent you the latest dev version via email (not yet on the Asset Store).
    Let me know if this works for you!

    (Same thing for others facing the issue, please send me an email).

    Thanks!
     
  20. oligraphics

    oligraphics

    Joined:
    Oct 9, 2018
    Posts:
    1
    Hello

    When running the build and opening a FileBrowser I get an error:

    NotSupportedException: System.Windows.Forms.CommonDialog::.ctor
    at System.Windows.Forms.CommonDialog..ctor () [0x00000] in <00000000000000000000000000000000>:0
    at PygmyMonkey.FileBrowser.Internal.FileBrowserWindowsNative.OpenFolder (System.String title, System.String startingDirectory, System.Action`1[T] onDone) [0x00000] in <00000000000000000000000000000000>:0
    at PygmyMonkey.FileBrowser.FileBrowserWindows.OpenFolderPanel (System.String title, System.String startingDirectory, System.Action`2[T1,T2] onDone) [0x00000] in <00000000000000000000000000000000>:0

    Im using:
    Scripting Runtime Version: .NET 4.x Equivalent
    Scripting Backend: IL2CPP
    Api Compatibility Level: .NET 4.x

    Any chance you could look into that? Right now the browser is not usable at all (it does not open). It does work in the editor though.
     
  21. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    I'm almost done working on version 2.0.0 that should fix everything for Windows.
    I'll write a message on the forum when it's done (hopefully very soon).

    In the meantime, if some people want to have this version before it's on the Asset Store, send me an email with your invoice number :)
    contact at pygmymonkey dot com

    Here's the changelog :
    "This release should fix everything regarding building on Windows.
    You can now use any setting :
    -- Scripting backend: Mono or IL2CPP
    -- Scripting runtime: .NET 3.5 or .NET 4.x
    -- Api Compatibility Level (for .NET 4.x): .NET Standard 2.0 or .NET 4.x
    -- Api Compatibility Level (for .NET 3.5): .NET 2.0 or .NET 2.0 Subset"
     
    Last edited: Jul 31, 2019
  22. MentalFish

    MentalFish

    Joined:
    Nov 2, 2005
    Posts:
    282
    Using this in the OSX version of Unity, with build target set to Windows, results in this error message: Assets/PygmyMonkey/FileBrowser/Scripts/FileBrowserWindows.cs(28,13): error CS0103: The name 'Internal' does not exist in the current context
    Any Idea why and how to get around it (without using a Windows machine to compile from)?
     
  23. elopez7

    elopez7

    Joined:
    Mar 8, 2014
    Posts:
    19
    Hi. I just bought this asset from the asset store. I tried the demo scene on playmode and it works beautifully and great, then I decided to make a build it doesn't work when I run the game. I click on the buttons and nothing happens, is there a specific way that I need to make the build?
    Here is what I am using.

    Unity 2019

    Scripting Backend: IL2CPP
    API Compatibility Level: .Net 4.x
    FullScreen Window.

    EDIT:
    Upon digging more in the issue I found that whenever I build the project it gives me this warning.

    Code (CSharp):
    1. System.Windows.Forms.dll assembly is referenced by user code, but is not supported on StandaloneWindows64 platform. Various failures might follow.
    2. UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
    Then the project builds, but clicking on the buttons does nothing.
    I switched to mono and I get the same warning, but this time clicking on the buttons works.
    I would stick to mono for now, but I need this to work with IL2CPP.

    Is there any kind of configuration setting I may be missing?
    Thank you.
     
    Last edited: Sep 22, 2019
  24. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    118
    I have precisely the same problem as the one mentioned above.
     
  25. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    Please send me an email (contact at pygmymonkey dot com) and I will send you an updated version that should fix the issue.
     
  26. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello!

    This is fixed in version 2.0, but it's not ready for now.
    I have one last critical issue to fix before it can be released, so you'll have to stick with Mono for now sorry.
     
  27. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,136
    FYI - I would prefer the code did not throw exceptions when you select a platform other than standalone/editor.
    Because I may have a scene in the same project that builds to another platform and does not use the FileBrowser code
     
  28. elopez7

    elopez7

    Joined:
    Mar 8, 2014
    Posts:
    19
    Ah, I see! I will stick to mono for now! Thank you very much for your response! I will update my review in the asset store accordingly.
     
  29. johnjoemcbob

    johnjoemcbob

    Joined:
    Jun 4, 2013
    Posts:
    1
    Hi, I'm having issues with the windows x64 support of the file browser. It works in the editor but in builds gives the following error;
    Code (CSharp):
    1. PlatformNotSupportedException: Operation is not supported on this platform.
    2.   at System.Windows.Forms.CommonDialog..ctor () [0x00000] in <7d6bd1867a7f46bbbe0a48e3546793a3>:0
    3.   at Ookii.Dialogs.VistaFileDialog..ctor () [0x00000] in <051ba73857bc4463af27719dd314623a>:0
    4.   at Ookii.Dialogs.VistaOpenFileDialog..ctor (System.Boolean forceDownlevel) [0x00000] in <051ba73857bc4463af27719dd314623a>:0
    5.   at Ookii.Dialogs.VistaOpenFileDialog..ctor () [0x00000] in <051ba73857bc4463af27719dd314623a>:0
    6.   at (wrapper remoting-invoke-with-check) Ookii.Dialogs.VistaOpenFileDialog..ctor()
    7.   at PygmyMonkey.FileBrowser.Internal.FileBrowserWindowsNative.OpenFile (System.String title, System.String startingDirectory, System.String extensionString, System.Boolean multiSelect, System.Action`1[T] onDone) [0x00000] in <051ba73857bc4463af27719dd314623a>:0
    8.   at PygmyMonkey.FileBrowser.FileBrowserWindows.OpenFilePanel (System.String title, System.String startingDirectory, System.String[] extensionArray, System.Action`2[T1,T2] onDone) [0x00029] in \Assets\PygmyMonkey\FileBrowser\Scripts\FileBrowserWindows.cs:28
    9.   at PygmyMonkey.FileBrowser.FileBrowser.OpenFilePanel (System.String title, System.String startingDirectory, System.String[] extensionArray, System.String buttonName, System.Action`2[T1,T2] onDone) [0x00001] in \Assets\PygmyMonkey\FileBrowser\Scripts\FileBrowser.cs:27
    10.  
    Unity 2020.1.3f1
    Windows _x86_64
    Scripting Backend - Mono
    API Level - .NET Standard 2.0
     
  30. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    Can you please send me an email (tools at pygmymonkey dot com) so I can send you the latest version?

    Thanks!
     
  31. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    An amateur programmer question: I don't understand *yet* how "return" thing works, can somebody please show me how to receive path to selected image as an variable I can use? Here is my code - got Native File Browser windows opening, file type filter set for *.jpg and *.png:
    Code (CSharp):
    1.        
    2. if (Input.GetKeyDown(KeyCode.F2))
    3. {
    4.        if (Cursor.lockState == CursorLockMode.Locked)
    5.        {
    6.              Cursor.lockState = CursorLockMode.Confined;
    7.        }
    8.        else
    9.        {
    10.            Cursor.lockState = CursorLockMode.Locked;
    11.         }
    12. }
    13. if (Input.GetKeyDown(KeyCode.F3))
    14. {
    15.       FileBrowser.OpenSingleFile("jpg,png");
    16. }
    17.  
     
  32. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi guys,

    I have a problem when I'm trying to upload the picked item on OSX:
    URL (): file:///Users/InfinityCoder/Desktop/RP_FavIconIos.png
    Code (CSharp):
    1. byte[] fileBytes = System.IO.File.ReadAllBytes(_url);
    Error:
    Code (CSharp):
    1. DirectoryNotFoundException: Could not find a part of the path "/Users/InfinityCoder/Documents/Unity Projects/UltimateUniversalApp/file:/Users/InfinityCoder/Desktop/RP_FavIconIos.png".
    2. System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <9577ac7a62ef43179789031239ba8798>:0)
    3. System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) (at <9577ac7a62ef43179789031239ba8798>:0)
    4. (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    5. System.IO.File.OpenRead (System.String path) (at <9577ac7a62ef43179789031239ba8798>:0)
    6. System.IO.File.ReadAllBytes (System.String path) (at <9577ac7a62ef43179789031239ba8798>:0)
    7. SocialApp.FeedDadaUoloader+<GetFile>d__23.MoveNext ()
    Any ideas why I get this error :( please help me with this, thanks in advance!
     
  33. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    There is no method call OpenSingleFile in NativeFileBrowser, maybe you're using a different asset?
    But to answer your question, you can just do this :
    Code (csharp):
    1.  
    2. string myFilePath = FileBrowser.OpenSingleFile("jpg,png");
    3.  
     
    Lex4art likes this.
  34. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    According to the error message, you're trying to open the file located at:
    which is not a valid path... (you can see twice /Users/InfinityCoder for example, and at the middle of the path, you have file:/)

    I don't know what you do to retrieve the "_url" variable, but there's something wrong here :)
     
  35. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    That simple... thank you very much, it's working )
     
  36. jamestrue

    jamestrue

    Joined:
    Jan 25, 2017
    Posts:
    5
    Bought this yesterday. Works great in Mac desktop but can't compile on Windows
    "Assets/PygmyMonkey/FileBrowser/Scripts/FileBrowserWindows.cs(72,13): error CS0103: The name 'Internal' does not exist in the current context"
     
    AviarLabs likes this.
  37. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    Can you send me an email so I can send you the latest version?

    Thanks!
     
  38. ghenryschmitt

    ghenryschmitt

    Joined:
    Jul 10, 2013
    Posts:
    8
    Hi, I've been using this asset for years and it's great, thank you.
    However, now I'm encountering an issue where I'm using it in a networked game; when someone has a file dialog open, it blocks the main thread and keeps network messages from being processed.
    Do you know what the easiest way would be to make this run without blocking the main thread? I tried calling it with async, but the dialog doesn't open if I do that...

    Thank you
     
  39. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    I'm not sure but maybe turning on "Run in background" option in Player settings will fix it.
     
  40. ghenryschmitt

    ghenryschmitt

    Joined:
    Jul 10, 2013
    Posts:
    8
    I already have that on
     
  41. ghenryschmitt

    ghenryschmitt

    Joined:
    Jul 10, 2013
    Posts:
    8
    Do you have any ideas on this? I've tried calling it from coroutines, using async, etc...
     
  42. ghenryschmitt

    ghenryschmitt

    Joined:
    Jul 10, 2013
    Posts:
    8
    Does anyone have an idea? Still can't get this to work...
     
  43. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello,

    I'm sorry for the long time to answer, looks like I missed your messages.
    And... I don't know how to do what you're asking...

    I think this is the default behaviour for most apps :/
     
  44. ghenryschmitt

    ghenryschmitt

    Joined:
    Jul 10, 2013
    Posts:
    8
    Hey,
    I'm just looking for the way to run it asynchronously and not block the main thread while the window is open, because if I run it with async it doesn't open. :/
     
  45. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    I understand, but I don't know how to do that :)
     
  46. s0phist

    s0phist

    Joined:
    Mar 30, 2011
    Posts:
    40
    Hi will you be supporting Apple Silicon?
     
  47. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Hello, unfortunately this is not planned for now :/
     
  48. richardzzzarnold

    richardzzzarnold

    Joined:
    Aug 2, 2012
    Posts:
    137
    Its kind of essential ....Not much use if it doesn't...
     
    JoeStrout likes this.
  49. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    Agreed. Apple only makes Apple Silicon now, so without that this plugin becomes pretty much a Windows Native File Browser. :(
     
    HdG_S likes this.
  50. PygmyMonkey

    PygmyMonkey

    Joined:
    Jan 13, 2014
    Posts:
    306
    Okay, I'll give it a try when I can :)
     
    HdG_S and JoeStrout like this.