Crate bevy_file_dialog
source ·Expand description
Bevy plugin that allows you to save and load files with file dialogs.
In order to use it you need to add FileDialogPlugin
to your App
with
at least one or more calls to:
FileDialogPlugin::with_save_file::<T>
FileDialogPlugin::with_load_file::<T>
FileDialogPlugin::with_pick_directory::<T>
FileDialogPlugin::with_pick_file::<T>
these functions can be called as many times as you want, the type parameter acts as marker that allows you to call:
FileDialog::save_file
FileDialog::load_file
FileDialog::load_multiple_files
FileDialog::pick_directory_path
FileDialog::pick_multiple_directory_paths
FileDialog::pick_file_path
FileDialog::pick_multiple_file_paths
with same type marker and then receive the result in
DialogFileSaved
(EventReader<DialogFileSaved<T>>
)DialogFileLoaded
(EventReader<DialogFileLoaded<T>>
)DialogDirectoryPicked
(EventReader<DialogDirectoryPicked<T>>
)DialogFilePicked
(EventReader<DialogFilePicked<T>>
)
events
FileDialog
can be created by calling FileDialogExt::dialog
,
FileDialogExt
as an extension trait implemented for Commands
and is included in bevy_file_dialog::prelude
:
fn system(mut commands: Commands) {
commands
.dialog()
.set_directory("/")
.set_title("My Save Dialog")
.add_filter("Text", &["txt"])
.save_file::<MySaveDialog>();
}
When you load multiple files at once with
FileDialog::load_multiple_files
, you receive them each as separate event
in EventReader<DialogFileLoaded<T>>
but they are sent as a batch,
meaning you get them all at once.
The same thing applies to FileDialog::pick_multiple_directory_paths
and
EventReader<DialogDirectoryPicked<T>>
and also
FileDialog::pick_multiple_file_paths
and
EventReader<DialogFilePicked<T>>
If you want to be compatible with wasm, do not use any of the pick_
apis,
they are only for native platforms.
Modules§
- Prelude containing all types you need for saving/loading files with dialogs.
Structs§
- Event that gets sent when user closes pick directory dialog without picking any directory.
- Event that gets sent when directory path gets selected from file system.
- Event that gets sent when user closes file load dialog without picking any file.
- Event that gets sent when file contents get loaded from file system.
- Event that gets sent when user closes pick file dialog without picking any file.
- Event that gets sent when file path gets selected from file system.
- Event that gets sent when user closes file save dialog without saving any file.
- Event that gets sent when file contents get saved to file system.
- File dialog for saving/loading files. You can further customize what can be saved/loaded and the initial state of dialog with its functions.
- Add this plugin to Bevy App to use the
FileDialog
resource in your system to save/load files.
Traits§
- Extension trait for
Commands
that allow you to create dialogs. - Marker trait saying that data can be loaded from file.
- Marker trait saying what directory path are we picking.
- Marker trait saying what file path are we picking.
- Marker trait saying that data can be saved to file.