Expand description
§Fix Cursor Unlock on Web
A tiny plugin that fixes Bevy not reporting when the cursor is unlocked on web
§Usage
Just add the plugin, that’s it:
use bevy::prelude::*;
use bevy_fix_cursor_unlock_web::prelude::*;
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(FixPointerUnlockPlugin);Now, Window::cursor_options::grab_mode is automatically set to CursorGrabMode::None for you when unlocking the cursor on web.
This fixes https://github.com/bevyengine/bevy/issues/8949
If you want to detect when a cursor was force freed, e.g. when the user presses escape, you can observe the ForceUnlockCursor event.
Note that Bevy does not forward the “Escape” key press in this case.
§Compatibility
| bevy | bevy_fix_cursor_unlock_web |
|---|---|
| 0.18 | 0.4 |
| 0.17 | 0.2 |
| 0.16 | 0.1 |
Modules§
- prelude
- Everything you need to fix the cursor unlock on web.
Structs§
- FixPointer
Unlock Plugin - A tiny plugin that updates all
Windows’CursorOptions::grab_modewhen the pointer is unlocked on Web. This fixes https://github.com/bevyengine/bevy/issues/8949. Does nothing on other platforms. - Force
Unlock Cursor - Event triggered when the cursor is forced to unlock, e.g. by pressing the Escape key when in fullscreen mode.