From 15db0b8df6c1583fa25c484791aa9d4fe2fa7430 Mon Sep 17 00:00:00 2001 From: Renato Caldas Date: Tue, 2 Feb 2021 11:12:38 +0000 Subject: [PATCH 1/2] Add support for reconfiguring a Plugin inside a PluginGroup --- crates/bevy_app/src/plugin_group.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/bevy_app/src/plugin_group.rs b/crates/bevy_app/src/plugin_group.rs index 074a2d3083cd2..19998e561e5ca 100644 --- a/crates/bevy_app/src/plugin_group.rs +++ b/crates/bevy_app/src/plugin_group.rs @@ -78,6 +78,18 @@ impl PluginGroupBuilder { self } + pub fn reconfigure(&mut self, plugin: T) -> &mut Self { + self.plugins.remove(&TypeId::of::()); + self.plugins.insert( + TypeId::of::(), + PluginEntry { + plugin: Box::new(plugin), + enabled: true, + }, + ); + self + } + pub fn enable(&mut self) -> &mut Self { let mut plugin_entry = self .plugins From 0801da89f45c4abe815ee513b629a507f2c177ce Mon Sep 17 00:00:00 2001 From: Renato Caldas Date: Tue, 2 Feb 2021 11:43:53 +0000 Subject: [PATCH 2/2] Add plugin reconfiguration example to app/plugin_group examples --- examples/app/plugin_group.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/app/plugin_group.rs b/examples/app/plugin_group.rs index 7e0be8143b6b3..09c0dc44a0aaa 100644 --- a/examples/app/plugin_group.rs +++ b/examples/app/plugin_group.rs @@ -13,6 +13,14 @@ fn main() { // .disable::() // .add_before::(bevy::diagnostic::LogDiagnosticsPlugin::default()) // }) + // Modifications can also include replacing the default configuration of a specific plugin: + // .add_plugins_with(DefaultPlugins, |group| { + // group + // .reconfigure(bevy::window::WindowPlugin { + // exit_on_close: false, + // ..Default::default() + // }) + // }) .run(); }