#Custom cursor import

3 messages · Page 1 of 1 (latest)

spice island
#

I want to change the cursor on the OS level.
But I get this import fail: error[E0432]: unresolved import bevy::winit::cursor::CustomCursorImage
--> src/main_menu.rs:4:41
|
4 | use bevy::winit::cursor::{CustomCursor, CustomCursorImage};
| ^^^^^^^^^^^^^^^^^
| |
| no CustomCursorImage in cursor
| help: a similar name exists in the module: CustomCursorCache

I have enable this feature in the cargo.toml file: bevy = { version = "0.15.3", features = ["custom_cursor"] }

lyric sail
#

CustomCursorImage is only showing on the docs for me for 0.16

crystal zephyr
#

@spice island you can use this to update your cursor with a custom img in 0.15

toml file:
bevy = "0.15.3"

main.rs

use bevy::prelude::*;
use bevy::winit::cursor::{CursorIcon, CustomCursor};

pub fn update_cursor(mut q_cursor: Query<&mut CursorIcon>, assets: Res<AssetServer>) {
    let Ok(mut cursor) = q_cursor.get_single_mut() else {
        return;
    };

    *cursor = CursorIcon::Custom(CustomCursor::Image {
        handle: assets.load("path/to/cursorImage.png"),
        hotspot: (0, 0),
    });
}