Skip to content

bran-jnw/FileBrowser

 
 

Repository files navigation

Archived – Now maintained in the Netherlands3D Main Repository; OpenUPM updates suspended.

Unity Standalone File Browser

Fork from https://github.com/gkngkc/UnityStandaloneFileBrowser to provide WebGL support.

A simple wrapper for native file dialogs on Windows/Mac/Linux.

  • Works in editor and runtime.
  • Open file/folder, save file dialogs supported.
  • Multiple file selection.
  • File extension filter.
  • Mono/IL2CPP backends supported.
  • Linux support by Ricardo Rodrigues.
  • WebGL support on Buttons.

Example Usage in interface:

Add the script "FileOpen.cs" to the button. Alt text

The selected files are copied to application.persistentDatapath. The filename(s) are sent as a string to the functions in OnFilesSelected. when there are multiple files selected, they are seperated with a comma ",".

Example usage in code:

// Open file
var paths = StandaloneFileBrowser.OpenFilePanel("Open File", "", "", false);

// Open file async
StandaloneFileBrowser.OpenFilePanelAsync("Open File", "", "", false, (string[] paths) => {  });

// Open file with filter
var extensions = new [] {
    new ExtensionFilter("Image Files", "png", "jpg", "jpeg" ),
    new ExtensionFilter("Sound Files", "mp3", "wav" ),
    new ExtensionFilter("All Files", "*" ),
};
var paths = StandaloneFileBrowser.OpenFilePanel("Open File", "", extensions, true);

// Save file
var path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "", "");

// Save file async
StandaloneFileBrowser.SaveFilePanelAsync("Save File", "", "", "", (string path) => {  });

// Save file with filter
var extensionList = new [] {
    new ExtensionFilter("Binary", "bin"),
    new ExtensionFilter("Text", "txt"),
};
var path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "MySaveFile", extensionList);

See Sample/BasicSampleScene.unity for more detailed examples.

Mac Screenshot Alt text

Windows Screenshot Alt text

Linux Screenshot Alt text

Notes:

  • Windows

    • Requires .NET 2.0 api compatibility level
    • Async dialog opening not implemented, ..Async methods simply calls regular sync methods.
    • Plugin import settings should be like this;

    Alt text Alt text

  • Mac

    • Sync calls are throws an exception at development build after native panel loses and gains focus. Use async calls to avoid this.

WebGL:

  • Basic upload/download file support.
  • File filter support.
  • Not well tested, probably not much reliable.
  • Since browsers require more work to do file operations, webgl isn't directly implemented to Open/Save calls. You can check CanvasSampleScene.unity and canvas sample scripts for example usages.

Live Demo: https://gkngkc.github.io/

Repository Archived

This repository has been archived and is no longer maintained independently.

The contents of this package have been merged into the
Netherlands3D Main Repository
into the Packages folder.

Current Location

The latest version and future updates of this package will be maintained inside the Netherlands3D main repository as part of an effort to simplify and unify our development workflow.

Why was this repository archived?

To streamline development and reduce overhead, the Netherlands3D packages are being integrated into the main repository.
This approach allows for better coordination between packages and features, while we continue to evaluate whether a full monorepo setup (including versioning) is desirable in the future.

Where to contribute

Please open issues and pull requests in the Netherlands3D Main Repository.

Publication status

Updates to this package on OpenUPM are suspended until further notice.
Future releases will be managed from the main repository once the new development flow has been finalized.

Historical reference

This repository remains available in read-only mode as a historical record of its standalone development.

About

A file browser for unity standalone and webGL platforms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 53.1%
  • JavaScript 25.1%
  • Objective-C++ 21.8%