6 releases
0.0.6 | Aug 20, 2024 |
---|---|
0.0.5 | Jul 9, 2024 |
0.0.4 | Jun 2, 2024 |
0.0.3 | Mar 6, 2024 |
0.0.2 | Jan 3, 2024 |
#928 in Game dev
9KB
71 lines
bevy_web_file_drop
Bevy plugin adding better support for drag and drop files in the web. Bevy has built in drag and drop events, but they cause a panic when used in a web build and don't cancel the default browser behavior. This plugin adds some custom JavaScript glue around the canvas to catch these events and relay them to Bevy.
lib.rs
:
Bevy plugin adding better support for drag and drop files in the web. Bevy has built in drag and drop support, but when used in a web build they cause a panic and don't cancel the default browser behaviors. This plugin adds some custom JavaScript glue around the canvas to catch these events and relay them safely to Bevy.
Usage
After adding the plugin, you can use the same Bevy FileDragAndDrop events to read dropped files.
The only difference is that the path_buf
field of the DroppedFile event will be a blob URL instead of a local file path.
This blob URL will be loadable as a Bevy asset using bevy_blob_loader.
You might not have to change any code at all! Just add in the plugin and dropped files should work in both native and web builds.
Dependencies
~32MB
~599K SLoC