From d4ffa3f490dbbd8eae0bebd2e3240f792bece714 Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Tue, 18 May 2021 00:10:18 +0000 Subject: [PATCH] Document what `Config` is and how to use it. (#2185) While trying to figure out how to implement a `SystemParam`, I spent a long time looking for a feature that would do exactly what `Config` does. I ignored it at first because all the examples I could find used `()` and I couldn't see a way to modify it. This is documented in other places, but `Config` is a logical place to include some breadcrumbs. I've added some text that gives a brief overview of what `Config` is for, and links to the existing docs on `FunctionSystem::config` for more details. This would have saved me from embarrassing myself by filing https://github.com/bevyengine/bevy/issues/2178. Co-authored-by: Carter Anderson --- crates/bevy_ecs/src/system/system_param.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index fda3684e6e..d4561740d6 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -49,6 +49,18 @@ pub trait SystemParam: Sized { /// Additionally, it is the implementor's responsibility to ensure there is no /// conflicting access across all SystemParams. pub unsafe trait SystemParamState: Send + Sync + 'static { + /// Values of this type can be used to adjust the behavior of the + /// system parameter. For instance, this can be used to pass + /// values from a `Plugin` to a `System`, or to control the + /// behavior of the `System`. + /// + /// The default configuration of the parameter is set by + /// [`SystemParamState::default_config`]. To change it, invoke + /// [`FunctionSystem::config`](super::FunctionSystem::config) when + /// creating the system. + /// + /// See [`FunctionSystem::config`](super::FunctionSystem::config) + /// for more information and examples. type Config: Send + Sync; fn init(world: &mut World, system_state: &mut SystemState, config: Self::Config) -> Self; #[inline]