From 66ad1bd063cccd857904c07ce09ca265567825f2 Mon Sep 17 00:00:00 2001 From: Nicola Papale Date: Thu, 21 Jul 2022 16:36:53 +0200 Subject: [PATCH] Remove off_screen_focusables example As it was added in https://github.com/bevyengine/bevy/pull/5252 --- Cargo.toml | 11 ---- .../ui_navigation/off_screen_focusables.rs | 61 ------------------- 2 files changed, 72 deletions(-) delete mode 100644 examples/ui_navigation/off_screen_focusables.rs diff --git a/Cargo.toml b/Cargo.toml index 8734ac95c7b0b..dcd7d82905e54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1469,17 +1469,6 @@ description = "Illustrates using Focusable on 3d entities" category = "UI navigation" wasm = true -[[example]] -name = "off_screen_focusables" -path = "examples/ui_navigation/off_screen_focusables.rs" - -[package.metadata.example.off_screen_focusables] -name = "Focusable wrapping" -description = "Illustrates wrapping within a menu" -category = "UI navigation" -wasm = true - - # Window [[example]] name = "clear_color" diff --git a/examples/ui_navigation/off_screen_focusables.rs b/examples/ui_navigation/off_screen_focusables.rs deleted file mode 100644 index 1b238f123eb73..0000000000000 --- a/examples/ui_navigation/off_screen_focusables.rs +++ /dev/null @@ -1,61 +0,0 @@ -use bevy::prelude::*; - -use bevy_ui_navigation::{DefaultNavigationPlugins, FocusState, Focusable, NavRequestSystem}; - -/// This example shows wrapping at screen edge, even when there are off-screen focusables. -fn main() { - App::new() - .add_plugins(DefaultPlugins) - .add_plugins(DefaultNavigationPlugins) - .add_startup_system(setup) - .add_system(button_system.after(NavRequestSystem)) - .run(); -} - -#[derive(Component)] -struct IdleColor(UiColor); - -fn button_system( - mut interaction_query: Query<(&Focusable, &mut UiColor, &IdleColor), Changed>, -) { - for (focusable, mut material, IdleColor(idle_color)) in interaction_query.iter_mut() { - if let FocusState::Focused = focusable.state() { - *material = Color::WHITE.into(); - } else { - *material = *idle_color; - } - } -} - -fn setup(mut commands: Commands) { - let top = 30; - let as_rainbow = |i: u32| Color::hsl((i as f32 / top as f32) * 360.0, 0.9, 0.5); - // ui camera - commands.spawn_bundle(Camera2dBundle::default()); - for i in 0..top { - for j in 0..top { - let full = (i + j).max(1); - spawn_button(&mut commands, as_rainbow((i * j) % full).into(), top, i, j); - } - } -} -fn spawn_button(commands: &mut Commands, color: UiColor, max: u32, i: u32, j: u32) { - let size = 340.0 / max as f32; - commands - .spawn_bundle(ButtonBundle { - color, - style: Style { - size: Size::new(Val::Percent(size), Val::Percent(size)), - position_type: PositionType::Absolute, - position: UiRect { - bottom: Val::Percent((400.0 / max as f32) * i as f32), - left: Val::Percent((400.0 / max as f32) * j as f32), - ..default() - }, - ..default() - }, - ..default() - }) - .insert(Focusable::default()) - .insert(IdleColor(color)); -}