A simple wrapper for native file dialogs on Windows/Mac/Linux.
Example usage:
// 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.
Notes:
Windows
Mac
WebGL:
Live Demo: https://gkngkc.github.io/
作用 打开对话框,获取所选文件路径 环境 Unity:Unity2021.3.6f1c1 准备 下载插件,插件地址Github 导入Unity 重要函数 public static string[] OpenFilePanel (string title, string directory, ExtensionFilter[] extensions, bool multiselect) 参