mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
1260b7bcf1
# Objective - Make it possible to react to arbitrary state changes - this will be useful regardless of the other changes to states currently being discussed ## Solution - added `StateTransitionEvent<S>` struct - previously, this would have been impossible: ```rs #[derive(States, Eq, PartialEq, Hash, Copy, Clone, Default)] enum MyState { #[default] Foo, Bar(MySubState), } enum MySubState { Spam, Eggs, } app.add_system(Update, on_enter_bar); fn on_enter_bar(trans: EventReader<StateTransition<MyState>>){ for (befoare, after) in trans.read() { match before, after { MyState::Foo, MyState::Bar(_) => info!("detected transition foo => bar"); _, _ => (); } } } ``` --- ## Changelog - Added - `StateTransitionEvent<S>` - Fired on state changes of `S` ## Migration Guide N/A no breaking changes --------- Co-authored-by: Federico Rinaldi <gisquerin@gmail.com> |
||
---|---|---|
.. | ||
apply_deferred.rs | ||
component_change_detection.rs | ||
custom_query_param.rs | ||
ecs_guide.rs | ||
event.rs | ||
fixed_timestep.rs | ||
generic_system.rs | ||
hierarchy.rs | ||
iter_combinations.rs | ||
nondeterministic_system_order.rs | ||
one_shot_systems.rs | ||
parallel_query.rs | ||
removal_detection.rs | ||
run_conditions.rs | ||
startup_system.rs | ||
state.rs | ||
system_closure.rs | ||
system_param.rs | ||
system_piping.rs |