bevyuipointercapturedetector

A plugin that detects if the mouse pointer is above a Bevy Ui Node. * supports Bevy 0.8

Usage

In your Cargo.toml [dependencies] section, add

toml bevy_ui_pointer_capture_detector = "0.2"

This example draws a square red UI node. Each update it sets the color of the background depending on if the mouse pointer is over the red node:

```rust

use bevy::prelude::; use bevy_ui_pointer_capture_detector::;

fn setup( mut commands: Commands ) { commands .spawnbundle(Camera2dBundle::default()) .commands() .spawnbundle(NodeBundle { style: Style { margin: UiRect { left: Val::Px(100.0), bottom: Val::Px(100.0), right: Val::Auto, top: Val::Auto }, size: Size { width: Val::Px(100.0), height: Val::Px(100.0) }, ..Default::default() }, color: UiColor(Color::RED), ..Default::default() }); }

fn ispointercaptured( iscaptured: Res, mut clearcolor: ResMut, ) { clearcolor.0 = if iscaptured.0 { Color::DARK_GRAY } else { Color::WHITE }; }

fn main() { App::new() .addplugins(DefaultPlugins) .addplugin(BevyUiPointerCaptureDetectorPlugin) .addstartupsystem(setup) .addsystem(ispointer_captured) .run(); } ``` #

Examples

cargo run --example example