diff --git a/Cargo.toml b/Cargo.toml index 3cd87c291c26a..b7a60becde543 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2246,7 +2246,6 @@ wasm = false name = "states" path = "examples/state/states.rs" doc-scrape-examples = true -required-features = ["bevy_dev_tools"] [package.metadata.example.states] name = "States" diff --git a/examples/state/states.rs b/examples/state/states.rs index b82a15d5fbf0f..f0a826218b060 100644 --- a/examples/state/states.rs +++ b/examples/state/states.rs @@ -5,11 +5,11 @@ //! //! In this case, we're transitioning from a `Menu` state to an `InGame` state. -use bevy::{dev_tools::states::*, prelude::*}; +use bevy::prelude::*; fn main() { - App::new() - .add_plugins(DefaultPlugins) + let mut app = App::new(); + app.add_plugins(DefaultPlugins) .init_state::() // Alternatively we could use .insert_state(AppState::Menu) .add_systems(Startup, setup) // This system runs when we enter `AppState::Menu`, during the `StateTransition` schedule. @@ -24,9 +24,14 @@ fn main() { .add_systems( Update, (movement, change_color).run_if(in_state(AppState::InGame)), - ) - .add_systems(Update, log_transitions::) - .run(); + ); + + #[cfg(feature = "bevy_dev_tools")] + app.add_systems(Update, bevy::dev_tools::states::log_transitions::); + #[cfg(not(feature = "bevy_dev_tools"))] + warn!("Enable feature bevy_dev_tools to log state transitions"); + + app.run(); } #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash, States)]