diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index d70669be5a1231..e188c3a1b149fe 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -359,7 +359,16 @@ impl App { // These are different for loops to avoid conflicting access to self for variant in S::variants() { self.add_schedule(OnEnter(variant.clone()), Schedule::new()); - self.add_schedule(OnExit(variant), Schedule::new()); + self.add_schedule(OnExit(variant.clone()), Schedule::new()); + + for second in S::variants() { + if second == variant { + // skip adding OnTransition for A -> A + continue; + } + + self.add_schedule(OnTransition(variant.clone(), second), Schedule::new()); + } } self diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index d8d8e5948a713e..d38e6962a33d93 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -43,8 +43,8 @@ pub mod prelude { schedule::{ apply_state_transition, apply_system_buffers, common_conditions::*, Condition, IntoSystemConfig, IntoSystemConfigs, IntoSystemSet, IntoSystemSetConfig, - IntoSystemSetConfigs, NextState, OnEnter, OnExit, OnUpdate, Schedule, Schedules, State, - States, SystemSet, + IntoSystemSetConfigs, NextState, OnEnter, OnExit, OnTransition, OnUpdate, Schedule, + Schedules, State, States, SystemSet, }, system::{ adapter as system_adapter,