#bevy-plugin #web #drop #drag #events #file #canvas

bevy_web_file_drop

Bevy plugin adding better support for drag and drop files in the web

3 releases

0.0.3 Mar 6, 2024
0.0.2 Jan 3, 2024
0.0.1 Jan 3, 2024

#807 in Game dev

Download history 27/week @ 2023-12-30 11/week @ 2024-02-17 3/week @ 2024-02-24 143/week @ 2024-03-02 22/week @ 2024-03-09 9/week @ 2024-03-16 1/week @ 2024-03-23 99/week @ 2024-03-30 31/week @ 2024-04-06 1/week @ 2024-04-13

133 downloads per month

MIT/Apache

9KB
64 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

~23–53MB
~857K SLoC