diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 87243af604..1d20222341 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -305,6 +305,8 @@ pub struct InputMarker; /// You get this by calling [`IntoSystem::into_system`] on a function that only accepts /// [`SystemParam`]s. The output of the system becomes the functions return type, while the input /// becomes the functions [`In`] tagged parameter or `()` if no such parameter exists. +/// +/// [`FunctionSystem`] must be `.initialized` before they can be run. pub struct FunctionSystem where Param: SystemParam, @@ -378,7 +380,7 @@ where let change_tick = world.increment_change_tick(); let out = self.func.run( input, - self.param_state.as_mut().unwrap(), + self.param_state.as_mut().expect("System's param_state was not found. Did you forget to initialize this system before running it?"), &self.system_meta, world, change_tick, @@ -389,7 +391,7 @@ where #[inline] fn apply_buffers(&mut self, world: &mut World) { - let param_state = self.param_state.as_mut().unwrap(); + let param_state = self.param_state.as_mut().expect("System's param_state was not found. Did you forget to initialize this system before running it?"); param_state.apply(world); }