Unity opens the file selection box (Standalone File Browser plug-in)

Function:

  • Works in editor and runtime.
    Support runtime + editor mode

  • Open file/folder, save file dialogs supported.
    Support opening files/folders, and saving files

  • Multiple file selection.
    Supports multiple file selection

  • File extension filter.
    Supports file suffix filtering

  • Mono/IL2CPP backends supported.

  • Basic WebGL support.
    Basic WebGL support, not extensively verified.

use:

// 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);

Git link

Further reading:

  • Ookii.Dialogs - Ookii.org - This is the solution to the file selection window under Windows in this repository, which solves the problem that the original window cannot be pinned to the top and is extremely ugly.

Guess you like

Origin blog.csdn.net/qq_38318701/article/details/129561914