Crates.io | bevy_cursor |
lib.rs | bevy_cursor |
version | 0.4.0 |
source | src |
created_at | 2023-08-11 19:08:07.105534 |
updated_at | 2024-07-06 08:58:17.701164 |
description | A bevy plugin to track information about the cursor |
homepage | |
repository | https://github.com/tguichaoua/bevy_cursor |
max_upload_size | |
id | 942198 |
size | 129,184 |
Bevy Cursor is a bevy
plugin to track information about the cursor.
This plugin will track information about the position of the cursor, the window, and the camera that contains it and compute the position of the pointed point in the world position system.
use bevy::prelude::*;
use bevy_cursor::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, TrackCursorPlugin))
.add_systems(Startup, setup)
.add_systems(Update, print_cursor_position)
.run();
}
fn setup(mut commands: Commands) {
// A camera is required to compute the world position of the cursor
commands.spawn(Camera2dBundle::default());
}
fn print_cursor_position(cursor: Res<CursorLocation>) {
if let Some(position) = cursor.position() {
info!("Cursor position: {position:?}");
} else {
info!("The cursor is not in any window");
}
}
2d
opt-in the computation of the world position of the cursor.3d
opt-in the computation of the ray emitted by the cursor through the camera.bevy | bevy_cursor |
---|---|
0.14 | 0.4 |
0.13 | 0.3 |
0.12 | 0.2 |
0.11 | 0.1 |