From f18f28874a683812dc5b8d54743b1826399897d9 Mon Sep 17 00:00:00 2001 From: Edgar Geier Date: Wed, 21 Jun 2023 22:51:03 +0200 Subject: [PATCH] Allow tuples and single plugins in `add_plugins`, deprecate `add_plugin` (#8097) # Objective - Better consistency with `add_systems`. - Deprecating `add_plugin` in favor of a more powerful `add_plugins`. - Allow passing `Plugin` to `add_plugins`. - Allow passing tuples to `add_plugins`. ## Solution - `App::add_plugins` now takes an `impl Plugins` parameter. - `App::add_plugin` is deprecated. - `Plugins` is a new sealed trait that is only implemented for `Plugin`, `PluginGroup` and tuples over `Plugins`. - All examples, benchmarks and tests are changed to use `add_plugins`, using tuples where appropriate. --- ## Changelog ### Changed - `App::add_plugins` now accepts all types that implement `Plugins`, which is implemented for: - Types that implement `Plugin`. - Types that implement `PluginGroup`. - Tuples (up to 16 elements) over types that implement `Plugins`. - Deprecated `App::add_plugin` in favor of `App::add_plugins`. ## Migration Guide - Replace `app.add_plugin(plugin)` calls with `app.add_plugins(plugin)`. --------- Co-authored-by: Carter Anderson --- crates/bevy_app/src/app.rs | 59 +++++++++++-------- crates/bevy_app/src/plugin.rs | 58 ++++++++++++++++++ crates/bevy_asset/src/asset_server.rs | 2 +- crates/bevy_asset/src/assets.rs | 8 ++- crates/bevy_asset/src/debug_asset_server.rs | 2 +- crates/bevy_asset/src/reflect.rs | 2 +- crates/bevy_audio/src/lib.rs | 4 +- crates/bevy_core/src/lib.rs | 11 ++-- crates/bevy_core_pipeline/src/bloom/mod.rs | 6 +- .../src/contrast_adaptive_sharpening/mod.rs | 6 +- crates/bevy_core_pipeline/src/core_2d/mod.rs | 2 +- crates/bevy_core_pipeline/src/core_3d/mod.rs | 3 +- crates/bevy_core_pipeline/src/fxaa/mod.rs | 2 +- crates/bevy_core_pipeline/src/lib.rs | 22 +++---- crates/bevy_core_pipeline/src/skybox/mod.rs | 2 +- .../bevy_core_pipeline/src/tonemapping/mod.rs | 8 ++- crates/bevy_diagnostic/src/diagnostic.rs | 2 +- crates/bevy_gizmos/src/lib.rs | 8 +-- crates/bevy_pbr/src/environment_map/mod.rs | 2 +- crates/bevy_pbr/src/lib.rs | 20 ++++--- crates/bevy_pbr/src/material.rs | 6 +- crates/bevy_pbr/src/render/fog.rs | 2 +- crates/bevy_pbr/src/render/mesh.rs | 2 +- crates/bevy_pbr/src/wireframe.rs | 6 +- crates/bevy_render/src/camera/mod.rs | 10 ++-- crates/bevy_render/src/lib.rs | 14 +++-- crates/bevy_render/src/mesh/mod.rs | 2 +- crates/bevy_render/src/texture/mod.rs | 2 +- crates/bevy_render/src/view/mod.rs | 3 +- crates/bevy_render/src/view/window.rs | 2 +- crates/bevy_sprite/src/lib.rs | 3 +- .../bevy_sprite/src/mesh2d/color_material.rs | 2 +- crates/bevy_sprite/src/mesh2d/material.rs | 2 +- crates/bevy_sprite/src/mesh2d/mesh.rs | 2 +- crates/bevy_transform/src/lib.rs | 2 +- crates/bevy_ui/src/lib.rs | 4 +- crates/bevy_winit/src/lib.rs | 4 +- examples/2d/custom_gltf_vertex_attribute.rs | 6 +- examples/2d/mesh2d_manual.rs | 3 +- examples/3d/anti_aliasing.rs | 3 +- examples/3d/lines.rs | 3 +- examples/3d/spotlight.rs | 8 ++- examples/3d/ssao.rs | 3 +- examples/3d/tonemapping.rs | 6 +- examples/3d/wireframe.rs | 16 ++--- examples/app/plugin.rs | 12 ++-- examples/app/plugin_group.rs | 10 ++-- examples/diagnostics/custom_diagnostic.rs | 10 ++-- examples/diagnostics/log_diagnostics.rs | 25 ++++---- examples/ecs/ecs_guide.rs | 2 +- examples/ecs/system_closure.rs | 2 +- examples/ecs/system_piping.rs | 2 +- examples/games/game_menu.rs | 4 +- examples/shader/animate_shader.rs | 3 +- examples/shader/array_texture.rs | 6 +- .../shader/compute_shader_game_of_life.rs | 18 +++--- examples/shader/custom_vertex_attribute.rs | 3 +- examples/shader/fallback_image.rs | 6 +- examples/shader/post_processing.rs | 21 ++++--- examples/shader/shader_defs.rs | 3 +- examples/shader/shader_instancing.rs | 5 +- examples/shader/shader_material.rs | 3 +- examples/shader/shader_material_glsl.rs | 3 +- .../shader_material_screenspace_texture.rs | 3 +- examples/shader/shader_prepass.rs | 30 +++++----- examples/shader/texture_binding_array.rs | 13 ++-- examples/stress_tests/bevymark.rs | 20 ++++--- .../stress_tests/many_animated_sprites.rs | 16 ++--- examples/stress_tests/many_buttons.rs | 16 ++--- examples/stress_tests/many_cubes.rs | 16 ++--- examples/stress_tests/many_foxes.rs | 18 +++--- examples/stress_tests/many_gizmos.rs | 16 ++--- examples/stress_tests/many_glyphs.rs | 16 ++--- examples/stress_tests/many_lights.rs | 22 +++---- examples/stress_tests/many_sprites.rs | 16 ++--- examples/stress_tests/text_pipeline.rs | 16 ++--- examples/stress_tests/transform_hierarchy.rs | 3 +- examples/tools/scene_viewer/main.rs | 8 +-- examples/ui/text.rs | 3 +- examples/ui/text_debug.rs | 14 +++-- examples/window/window_settings.rs | 30 +++++----- 81 files changed, 438 insertions(+), 321 deletions(-) diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 0c3a7d89d1..aff7afe904 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1,6 +1,4 @@ -use crate::{ - First, Main, MainSchedulePlugin, Plugin, PluginGroup, Startup, StateTransition, Update, -}; +use crate::{First, Main, MainSchedulePlugin, Plugin, Plugins, Startup, StateTransition, Update}; pub use bevy_derive::AppLabel; use bevy_ecs::{ prelude::*, @@ -18,6 +16,7 @@ use std::{ #[cfg(feature = "trace")] use bevy_utils::tracing::info_span; + bevy_utils::define_label!( /// A strongly-typed class of labels used to identify an [`App`]. AppLabel, @@ -183,7 +182,7 @@ impl Default for App { #[cfg(feature = "bevy_reflect")] app.init_resource::(); - app.add_plugin(MainSchedulePlugin); + app.add_plugins(MainSchedulePlugin); app.add_event::(); #[cfg(feature = "bevy_ci_testing")] @@ -685,19 +684,16 @@ impl App { /// # Panics /// /// Panics if the plugin was already added to the application. + #[deprecated(since = "0.11.0", note = "Please use `add_plugins` instead.")] pub fn add_plugin(&mut self, plugin: T) -> &mut Self where T: Plugin, { - match self.add_boxed_plugin(Box::new(plugin)) { - Ok(app) => app, - Err(AppError::DuplicatePlugin { plugin_name }) => panic!( - "Error adding plugin {plugin_name}: : plugin was already added in application" - ), - } + self.add_plugins(plugin) } - /// Boxed variant of [`add_plugin`](App::add_plugin) that can be used from a [`PluginGroup`] + /// Boxed variant of [`add_plugin`](App::add_plugin) that can be used from a + /// [`PluginGroup`](super::PluginGroup) pub(crate) fn add_boxed_plugin( &mut self, plugin: Box, @@ -752,7 +748,7 @@ impl App { /// # fn build(&self, app: &mut App) {} /// # } /// # let mut app = App::new(); - /// # app.add_plugin(ImagePlugin::default()); + /// # app.add_plugins(ImagePlugin::default()); /// let default_sampler = app.get_added_plugins::()[0].default_sampler; /// ``` pub fn get_added_plugins(&self) -> Vec<&T> @@ -765,7 +761,10 @@ impl App { .collect() } - /// Adds a group of [`Plugin`]s. + /// Adds one or more [`Plugin`]s. + /// + /// One of Bevy's core principles is modularity. All Bevy engine features are implemented + /// as [`Plugin`]s. This includes internal features like the renderer. /// /// [`Plugin`]s can be grouped into a set by using a [`PluginGroup`]. /// @@ -773,23 +772,35 @@ impl App { /// The [`PluginGroup`]s available by default are `DefaultPlugins` and `MinimalPlugins`. /// /// To customize the plugins in the group (reorder, disable a plugin, add a new plugin - /// before / after another plugin), call [`build()`](PluginGroup::build) on the group, + /// before / after another plugin), call [`build()`](super::PluginGroup::build) on the group, /// which will convert it to a [`PluginGroupBuilder`](crate::PluginGroupBuilder). /// + /// You can also specify a group of [`Plugin`]s by using a tuple over [`Plugin`]s and + /// [`PluginGroup`]s. See [`Plugins`] for more details. + /// /// ## Examples /// ``` /// # use bevy_app::{prelude::*, PluginGroupBuilder, NoopPluginGroup as MinimalPlugins}; /// # + /// # // Dummies created to avoid using `bevy_log`, + /// # // which pulls in too many dependencies and breaks rust-analyzer + /// # pub struct LogPlugin; + /// # impl Plugin for LogPlugin { + /// # fn build(&self, app: &mut App) {} + /// # } /// App::new() /// .add_plugins(MinimalPlugins); + /// App::new() + /// .add_plugins((MinimalPlugins, LogPlugin)); /// ``` /// /// # Panics /// - /// Panics if one of the plugin in the group was already added to the application. - pub fn add_plugins(&mut self, group: T) -> &mut Self { - let builder = group.build(); - builder.finish(self); + /// Panics if one of the plugins was already added to the application. + /// + /// [`PluginGroup`]:super::PluginGroup + pub fn add_plugins(&mut self, plugins: impl Plugins) -> &mut Self { + plugins.add_to_app(self); self } @@ -1006,23 +1017,23 @@ mod tests { #[test] fn can_add_two_plugins() { - App::new().add_plugin(PluginA).add_plugin(PluginB); + App::new().add_plugins((PluginA, PluginB)); } #[test] #[should_panic] fn cant_add_twice_the_same_plugin() { - App::new().add_plugin(PluginA).add_plugin(PluginA); + App::new().add_plugins((PluginA, PluginA)); } #[test] fn can_add_twice_the_same_plugin_with_different_type_param() { - App::new().add_plugin(PluginC(0)).add_plugin(PluginC(true)); + App::new().add_plugins((PluginC(0), PluginC(true))); } #[test] fn can_add_twice_the_same_plugin_not_unique() { - App::new().add_plugin(PluginD).add_plugin(PluginD); + App::new().add_plugins((PluginD, PluginD)); } #[test] @@ -1035,10 +1046,10 @@ mod tests { } impl Plugin for PluginRun { fn build(&self, app: &mut crate::App) { - app.add_plugin(InnerPlugin).run(); + app.add_plugins(InnerPlugin).run(); } } - App::new().add_plugin(PluginRun); + App::new().add_plugins(PluginRun); } #[derive(States, PartialEq, Eq, Debug, Default, Hash, Clone)] diff --git a/crates/bevy_app/src/plugin.rs b/crates/bevy_app/src/plugin.rs index 725ebbe195..12e7d1f1c8 100644 --- a/crates/bevy_app/src/plugin.rs +++ b/crates/bevy_app/src/plugin.rs @@ -65,3 +65,61 @@ impl_downcast!(Plugin); /// /// See `bevy_dynamic_plugin/src/loader.rs#dynamically_load_plugin`. pub type CreatePlugin = unsafe fn() -> *mut dyn Plugin; + +/// Types that represent a set of [`Plugin`]s. +/// +/// This is implemented for all types which implement [`Plugin`], +/// [`PluginGroup`](super::PluginGroup), and tuples over [`Plugins`]. +pub trait Plugins: sealed::Plugins {} + +impl Plugins for T where T: sealed::Plugins {} + +mod sealed { + + use bevy_ecs::all_tuples; + + use crate::{App, AppError, Plugin, PluginGroup}; + + pub trait Plugins { + fn add_to_app(self, app: &mut App); + } + + pub struct PluginMarker; + pub struct PluginGroupMarker; + pub struct PluginsTupleMarker; + + impl Plugins for P { + fn add_to_app(self, app: &mut App) { + if let Err(AppError::DuplicatePlugin { plugin_name }) = + app.add_boxed_plugin(Box::new(self)) + { + panic!( + "Error adding plugin {plugin_name}: : plugin was already added in application" + ) + } + } + } + + impl Plugins for P { + fn add_to_app(self, app: &mut App) { + self.build().finish(app); + } + } + + macro_rules! impl_plugins_tuples { + ($(($param: ident, $plugins: ident)),*) => { + impl<$($param, $plugins),*> Plugins<(PluginsTupleMarker, $($param,)*)> for ($($plugins,)*) + where + $($plugins: Plugins<$param>),* + { + #[allow(non_snake_case, unused_variables)] + fn add_to_app(self, app: &mut App) { + let ($($plugins,)*) = self; + $($plugins.add_to_app(app);)* + } + } + } + } + + all_tuples!(impl_plugins_tuples, 0, 15, P, S); +} diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index e7e830cd1d..d97f206bbd 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -85,7 +85,7 @@ pub struct AssetServerInternal { /// # use bevy_utils::Duration; /// # let mut app = App::new(); /// // The asset plugin can be configured to watch for asset changes. -/// app.add_plugin(AssetPlugin { +/// app.add_plugins(AssetPlugin { /// watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)), /// ..Default::default() /// }); diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index fb9ac6cb93..a27e30cb01 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -494,9 +494,11 @@ mod tests { #[uuid = "44115972-f31b-46e5-be5c-2b9aece6a52f"] struct MyAsset; let mut app = App::new(); - app.add_plugin(bevy_core::TaskPoolPlugin::default()) - .add_plugin(bevy_core::TypeRegistrationPlugin::default()) - .add_plugin(crate::AssetPlugin::default()); + app.add_plugins(( + bevy_core::TaskPoolPlugin::default(), + bevy_core::TypeRegistrationPlugin::default(), + crate::AssetPlugin::default(), + )); app.add_asset::(); let mut assets_before = app.world.resource_mut::>(); let handle = assets_before.add(MyAsset); diff --git a/crates/bevy_asset/src/debug_asset_server.rs b/crates/bevy_asset/src/debug_asset_server.rs index 93595020ec..6c2e3d4815 100644 --- a/crates/bevy_asset/src/debug_asset_server.rs +++ b/crates/bevy_asset/src/debug_asset_server.rs @@ -71,7 +71,7 @@ impl Plugin for DebugAssetServerPlugin { .build() }); let mut debug_asset_app = App::new(); - debug_asset_app.add_plugin(AssetPlugin { + debug_asset_app.add_plugins(AssetPlugin { asset_folder: "crates".to_string(), watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)), }); diff --git a/crates/bevy_asset/src/reflect.rs b/crates/bevy_asset/src/reflect.rs index 0e735724b0..cade543c20 100644 --- a/crates/bevy_asset/src/reflect.rs +++ b/crates/bevy_asset/src/reflect.rs @@ -268,7 +268,7 @@ mod tests { #[test] fn test_reflect_asset_operations() { let mut app = App::new(); - app.add_plugin(AssetPlugin::default()) + app.add_plugins(AssetPlugin::default()) .add_asset::() .register_asset_reflect::(); diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index d703673191..6544c78969 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -7,9 +7,7 @@ //! # use bevy_app::{App, AppExit, NoopPluginGroup as MinimalPlugins, Startup}; //! fn main() { //! App::new() -//! .add_plugins(MinimalPlugins) -//! .add_plugin(AssetPlugin::default()) -//! .add_plugin(AudioPlugin::default()) +//! .add_plugins((MinimalPlugins, AssetPlugin::default(), AudioPlugin::default())) //! .add_systems(Startup, play_background_audio) //! .run(); //! } diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index 055e92c7dd..a9b10b1e81 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -165,8 +165,7 @@ mod tests { #[test] fn runs_spawn_local_tasks() { let mut app = App::new(); - app.add_plugin(TaskPoolPlugin::default()); - app.add_plugin(TypeRegistrationPlugin::default()); + app.add_plugins((TaskPoolPlugin::default(), TypeRegistrationPlugin::default())); let (async_tx, async_rx) = crossbeam_channel::unbounded(); AsyncComputeTaskPool::get() @@ -199,9 +198,11 @@ mod tests { #[test] fn frame_counter_update() { let mut app = App::new(); - app.add_plugin(TaskPoolPlugin::default()); - app.add_plugin(TypeRegistrationPlugin::default()); - app.add_plugin(FrameCountPlugin::default()); + app.add_plugins(( + TaskPoolPlugin::default(), + TypeRegistrationPlugin::default(), + FrameCountPlugin::default(), + )); app.update(); let frame_count = app.world.resource::(); diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 9991da1ee2..e5271544e2 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -52,8 +52,10 @@ impl Plugin for BloomPlugin { app.register_type::(); app.register_type::(); app.register_type::(); - app.add_plugin(ExtractComponentPlugin::::default()); - app.add_plugin(UniformComponentPlugin::::default()); + app.add_plugins(( + ExtractComponentPlugin::::default(), + UniformComponentPlugin::::default(), + )); let render_app = match app.get_sub_app_mut(RenderApp) { Ok(render_app) => render_app, diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index cdb57d03e6..b26c02b547 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -108,8 +108,10 @@ impl Plugin for CASPlugin { ); app.register_type::(); - app.add_plugin(ExtractComponentPlugin::::default()); - app.add_plugin(UniformComponentPlugin::::default()); + app.add_plugins(( + ExtractComponentPlugin::::default(), + UniformComponentPlugin::::default(), + )); let render_app = match app.get_sub_app_mut(RenderApp) { Ok(render_app) => render_app, diff --git a/crates/bevy_core_pipeline/src/core_2d/mod.rs b/crates/bevy_core_pipeline/src/core_2d/mod.rs index 19e0375f67..d3d12130b3 100644 --- a/crates/bevy_core_pipeline/src/core_2d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_2d/mod.rs @@ -45,7 +45,7 @@ pub struct Core2dPlugin; impl Plugin for Core2dPlugin { fn build(&self, app: &mut App) { app.register_type::() - .add_plugin(ExtractComponentPlugin::::default()); + .add_plugins(ExtractComponentPlugin::::default()); let render_app = match app.get_sub_app_mut(RenderApp) { Ok(render_app) => render_app, diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index 5d9a42989d..29e7157165 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -69,8 +69,7 @@ impl Plugin for Core3dPlugin { fn build(&self, app: &mut App) { app.register_type::() .register_type::() - .add_plugin(SkyboxPlugin) - .add_plugin(ExtractComponentPlugin::::default()); + .add_plugins((SkyboxPlugin, ExtractComponentPlugin::::default())); let render_app = match app.get_sub_app_mut(RenderApp) { Ok(render_app) => render_app, diff --git a/crates/bevy_core_pipeline/src/fxaa/mod.rs b/crates/bevy_core_pipeline/src/fxaa/mod.rs index 4ddcb84e21..e153a77b62 100644 --- a/crates/bevy_core_pipeline/src/fxaa/mod.rs +++ b/crates/bevy_core_pipeline/src/fxaa/mod.rs @@ -87,7 +87,7 @@ impl Plugin for FxaaPlugin { load_internal_asset!(app, FXAA_SHADER_HANDLE, "fxaa.wgsl", Shader::from_wgsl); app.register_type::(); - app.add_plugin(ExtractComponentPlugin::::default()); + app.add_plugins(ExtractComponentPlugin::::default()); let render_app = match app.get_sub_app_mut(RenderApp) { Ok(render_app) => render_app, diff --git a/crates/bevy_core_pipeline/src/lib.rs b/crates/bevy_core_pipeline/src/lib.rs index f169cdd89e..51e5ae3627 100644 --- a/crates/bevy_core_pipeline/src/lib.rs +++ b/crates/bevy_core_pipeline/src/lib.rs @@ -68,15 +68,17 @@ impl Plugin for CorePipelinePlugin { .register_type::() .register_type::() .init_resource::() - .add_plugin(ExtractResourcePlugin::::default()) - .add_plugin(Core2dPlugin) - .add_plugin(Core3dPlugin) - .add_plugin(BlitPlugin) - .add_plugin(MsaaWritebackPlugin) - .add_plugin(TonemappingPlugin) - .add_plugin(UpscalingPlugin) - .add_plugin(BloomPlugin) - .add_plugin(FxaaPlugin) - .add_plugin(CASPlugin); + .add_plugins(( + ExtractResourcePlugin::::default(), + Core2dPlugin, + Core3dPlugin, + BlitPlugin, + MsaaWritebackPlugin, + TonemappingPlugin, + UpscalingPlugin, + BloomPlugin, + FxaaPlugin, + CASPlugin, + )); } } diff --git a/crates/bevy_core_pipeline/src/skybox/mod.rs b/crates/bevy_core_pipeline/src/skybox/mod.rs index 7917c9efb5..ccf21334aa 100644 --- a/crates/bevy_core_pipeline/src/skybox/mod.rs +++ b/crates/bevy_core_pipeline/src/skybox/mod.rs @@ -34,7 +34,7 @@ impl Plugin for SkyboxPlugin { fn build(&self, app: &mut App) { load_internal_asset!(app, SKYBOX_SHADER_HANDLE, "skybox.wgsl", Shader::from_wgsl); - app.add_plugin(ExtractComponentPlugin::::default()); + app.add_plugins(ExtractComponentPlugin::::default()); let render_app = match app.get_sub_app_mut(RenderApp) { Ok(render_app) => render_app, diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index 4fc33fda37..0896c37f3e 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -82,13 +82,15 @@ impl Plugin for TonemappingPlugin { app.insert_resource(tonemapping_luts); } - app.add_plugin(ExtractResourcePlugin::::default()); + app.add_plugins(ExtractResourcePlugin::::default()); app.register_type::(); app.register_type::(); - app.add_plugin(ExtractComponentPlugin::::default()); - app.add_plugin(ExtractComponentPlugin::::default()); + app.add_plugins(( + ExtractComponentPlugin::::default(), + ExtractComponentPlugin::::default(), + )); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_diagnostic/src/diagnostic.rs b/crates/bevy_diagnostic/src/diagnostic.rs index 934de2676a..6fa04ce573 100644 --- a/crates/bevy_diagnostic/src/diagnostic.rs +++ b/crates/bevy_diagnostic/src/diagnostic.rs @@ -299,7 +299,7 @@ impl RegisterDiagnostic for App { /// /// App::new() /// .register_diagnostic(Diagnostic::new(UNIQUE_DIAG_ID, "example", 10)) - /// .add_plugin(DiagnosticsPlugin) + /// .add_plugins(DiagnosticsPlugin) /// .run(); /// ``` fn register_diagnostic(&mut self, diagnostic: Diagnostic) -> &mut Self { diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index b288d72f74..3a6b89f3e0 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -78,9 +78,9 @@ impl Plugin for GizmoPlugin { fn build(&self, app: &mut bevy_app::App) { load_internal_asset!(app, LINE_SHADER_HANDLE, "lines.wgsl", Shader::from_wgsl); - app.add_plugin(UniformComponentPlugin::::default()) + app.add_plugins(UniformComponentPlugin::::default()) .add_asset::() - .add_plugin(RenderAssetPlugin::::default()) + .add_plugins(RenderAssetPlugin::::default()) .init_resource::() .init_resource::() .init_resource::() @@ -100,9 +100,9 @@ impl Plugin for GizmoPlugin { .add_systems(Render, queue_line_gizmo_bind_group.in_set(RenderSet::Queue)); #[cfg(feature = "bevy_sprite")] - app.add_plugin(pipeline_2d::LineGizmo2dPlugin); + app.add_plugins(pipeline_2d::LineGizmo2dPlugin); #[cfg(feature = "bevy_pbr")] - app.add_plugin(pipeline_3d::LineGizmo3dPlugin); + app.add_plugins(pipeline_3d::LineGizmo3dPlugin); } fn finish(&self, app: &mut bevy_app::App) { diff --git a/crates/bevy_pbr/src/environment_map/mod.rs b/crates/bevy_pbr/src/environment_map/mod.rs index 0b0250268b..7e6e873202 100644 --- a/crates/bevy_pbr/src/environment_map/mod.rs +++ b/crates/bevy_pbr/src/environment_map/mod.rs @@ -28,7 +28,7 @@ impl Plugin for EnvironmentMapPlugin { ); app.register_type::() - .add_plugin(ExtractComponentPlugin::::default()); + .add_plugins(ExtractComponentPlugin::::default()); } } diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 0f146ed121..2460a0e0f6 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -182,18 +182,21 @@ impl Plugin for PbrPlugin { .register_type::() .register_type::() .register_type::() - .add_plugin(MeshRenderPlugin) - .add_plugin(MaterialPlugin:: { - prepass_enabled: self.prepass_enabled, - ..Default::default() - }) - .add_plugin(ScreenSpaceAmbientOcclusionPlugin) - .add_plugin(EnvironmentMapPlugin) .init_resource::() .init_resource::() .init_resource::() .init_resource::() - .add_plugin(ExtractResourcePlugin::::default()) + .add_plugins(( + MeshRenderPlugin, + MaterialPlugin:: { + prepass_enabled: self.prepass_enabled, + ..Default::default() + }, + ScreenSpaceAmbientOcclusionPlugin, + EnvironmentMapPlugin, + ExtractResourcePlugin::::default(), + FogPlugin, + )) .configure_sets( PostUpdate, ( @@ -203,7 +206,6 @@ impl Plugin for PbrPlugin { ) .chain(), ) - .add_plugin(FogPlugin) .add_systems( PostUpdate, ( diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 559c880051..5741419674 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -188,7 +188,7 @@ where { fn build(&self, app: &mut App) { app.add_asset::() - .add_plugin(ExtractComponentPlugin::>::extract_visible()); + .add_plugins(ExtractComponentPlugin::>::extract_visible()); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app @@ -214,10 +214,10 @@ where } // PrepassPipelinePlugin is required for shadow mapping and the optional PrepassPlugin - app.add_plugin(PrepassPipelinePlugin::::default()); + app.add_plugins(PrepassPipelinePlugin::::default()); if self.prepass_enabled { - app.add_plugin(PrepassPlugin::::default()); + app.add_plugins(PrepassPlugin::::default()); } } diff --git a/crates/bevy_pbr/src/render/fog.rs b/crates/bevy_pbr/src/render/fog.rs index bd58605899..6c314ccd04 100644 --- a/crates/bevy_pbr/src/render/fog.rs +++ b/crates/bevy_pbr/src/render/fog.rs @@ -138,7 +138,7 @@ impl Plugin for FogPlugin { load_internal_asset!(app, FOG_SHADER_HANDLE, "fog.wgsl", Shader::from_wgsl); app.register_type::(); - app.add_plugin(ExtractComponentPlugin::::default()); + app.add_plugins(ExtractComponentPlugin::::default()); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index 20cb2a1986..a6049589d9 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -102,7 +102,7 @@ impl Plugin for MeshRenderPlugin { load_internal_asset!(app, MESH_SHADER_HANDLE, "mesh.wgsl", Shader::from_wgsl); load_internal_asset!(app, SKINNING_HANDLE, "skinning.wgsl", Shader::from_wgsl); - app.add_plugin(UniformComponentPlugin::::default()); + app.add_plugins(UniformComponentPlugin::::default()); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index d31590c78e..d3c8b3ba47 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -40,8 +40,10 @@ impl Plugin for WireframePlugin { app.register_type::() .register_type::() .init_resource::() - .add_plugin(ExtractResourcePlugin::::default()) - .add_plugin(ExtractComponentPlugin::::default()); + .add_plugins(( + ExtractResourcePlugin::::default(), + ExtractComponentPlugin::::default(), + )); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_render/src/camera/mod.rs b/crates/bevy_render/src/camera/mod.rs index 3829d392c0..b57ae98dc7 100644 --- a/crates/bevy_render/src/camera/mod.rs +++ b/crates/bevy_render/src/camera/mod.rs @@ -28,10 +28,12 @@ impl Plugin for CameraPlugin { .register_type::() .register_type::() .init_resource::() - .add_plugin(CameraProjectionPlugin::::default()) - .add_plugin(CameraProjectionPlugin::::default()) - .add_plugin(CameraProjectionPlugin::::default()) - .add_plugin(ExtractResourcePlugin::::default()); + .add_plugins(( + CameraProjectionPlugin::::default(), + CameraProjectionPlugin::::default(), + CameraProjectionPlugin::::default(), + ExtractResourcePlugin::::default(), + )); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 3df8d22954..f715bcc719 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -329,12 +329,14 @@ impl Plugin for RenderPlugin { })); } - app.add_plugin(ValidParentCheckPlugin::::default()) - .add_plugin(WindowRenderPlugin) - .add_plugin(CameraPlugin) - .add_plugin(ViewPlugin) - .add_plugin(MeshPlugin) - .add_plugin(GlobalsPlugin); + app.add_plugins(( + ValidParentCheckPlugin::::default(), + WindowRenderPlugin, + CameraPlugin, + ViewPlugin, + MeshPlugin, + GlobalsPlugin, + )); app.register_type::() .register_type::() diff --git a/crates/bevy_render/src/mesh/mod.rs b/crates/bevy_render/src/mesh/mod.rs index 790d4531b2..8042f9c6d9 100644 --- a/crates/bevy_render/src/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mod.rs @@ -19,6 +19,6 @@ impl Plugin for MeshPlugin { .add_asset::() .register_type::() .register_type::>() - .add_plugin(RenderAssetPlugin::::default()); + .add_plugins(RenderAssetPlugin::::default()); } } diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index bba263beaa..6d4fd23bb6 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -93,7 +93,7 @@ impl Plugin for ImagePlugin { app.init_asset_loader::(); } - app.add_plugin(RenderAssetPlugin::::with_prepare_asset_set( + app.add_plugins(RenderAssetPlugin::::with_prepare_asset_set( PrepareAssetSet::PreAssetPrepare, )) .register_type::() diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index e4bd033e15..9c09fb8bf6 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -50,8 +50,7 @@ impl Plugin for ViewPlugin { .register_type::() .init_resource::() // NOTE: windows.is_changed() handles cases where a window was resized - .add_plugin(ExtractResourcePlugin::::default()) - .add_plugin(VisibilityPlugin); + .add_plugins((ExtractResourcePlugin::::default(), VisibilityPlugin)); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_render/src/view/window.rs b/crates/bevy_render/src/view/window.rs index d022d4cc53..e76097004a 100644 --- a/crates/bevy_render/src/view/window.rs +++ b/crates/bevy_render/src/view/window.rs @@ -34,7 +34,7 @@ pub enum WindowSystem { impl Plugin for WindowRenderPlugin { fn build(&self, app: &mut App) { - app.add_plugin(ScreenshotPlugin); + app.add_plugins(ScreenshotPlugin); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_sprite/src/lib.rs b/crates/bevy_sprite/src/lib.rs index 403e00722e..fd63b19579 100644 --- a/crates/bevy_sprite/src/lib.rs +++ b/crates/bevy_sprite/src/lib.rs @@ -65,8 +65,7 @@ impl Plugin for SpritePlugin { .register_type::() .register_type::() .register_type::() - .add_plugin(Mesh2dRenderPlugin) - .add_plugin(ColorMaterialPlugin) + .add_plugins((Mesh2dRenderPlugin, ColorMaterialPlugin)) .add_systems( PostUpdate, calculate_bounds_2d.in_set(VisibilitySystems::CalculateBounds), diff --git a/crates/bevy_sprite/src/mesh2d/color_material.rs b/crates/bevy_sprite/src/mesh2d/color_material.rs index 57c57deb2b..75ba440beb 100644 --- a/crates/bevy_sprite/src/mesh2d/color_material.rs +++ b/crates/bevy_sprite/src/mesh2d/color_material.rs @@ -23,7 +23,7 @@ impl Plugin for ColorMaterialPlugin { Shader::from_wgsl ); - app.add_plugin(Material2dPlugin::::default()) + app.add_plugins(Material2dPlugin::::default()) .register_asset_reflect::(); app.world diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index b33c7a5702..2ba6765e72 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -152,7 +152,7 @@ where { fn build(&self, app: &mut App) { app.add_asset::() - .add_plugin(ExtractComponentPlugin::>::extract_visible()); + .add_plugins(ExtractComponentPlugin::>::extract_visible()); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 7161141525..137f412c38 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -97,7 +97,7 @@ impl Plugin for Mesh2dRenderPlugin { ); load_internal_asset!(app, MESH2D_SHADER_HANDLE, "mesh2d.wgsl", Shader::from_wgsl); - app.add_plugin(UniformComponentPlugin::::default()); + app.add_plugins(UniformComponentPlugin::::default()); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app diff --git a/crates/bevy_transform/src/lib.rs b/crates/bevy_transform/src/lib.rs index c8b01c1098..50444acd8b 100644 --- a/crates/bevy_transform/src/lib.rs +++ b/crates/bevy_transform/src/lib.rs @@ -101,7 +101,7 @@ impl Plugin for TransformPlugin { app.register_type::() .register_type::() - .add_plugin(ValidParentCheckPlugin::::default()) + .add_plugins(ValidParentCheckPlugin::::default()) .configure_set( PostStartup, PropagateTransformsSet.in_set(TransformSystem::TransformPropagate), diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index a2eb9980ed..d5669288c3 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -81,7 +81,7 @@ impl Default for UiScale { impl Plugin for UiPlugin { fn build(&self, app: &mut App) { - app.add_plugin(ExtractComponentPlugin::::default()) + app.add_plugins(ExtractComponentPlugin::::default()) .init_resource::() .init_resource::() .init_resource::() @@ -144,7 +144,7 @@ impl Plugin for UiPlugin { ), ); #[cfg(feature = "bevy_text")] - app.add_plugin(accessibility::AccessibilityPlugin); + app.add_plugins(accessibility::AccessibilityPlugin); app.add_systems(PostUpdate, { let system = widget::update_image_content_size_system.before(UiSystem::Layout); // Potential conflicts: `Assets` diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 900d4126b4..ac4db6d29f 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -99,10 +99,10 @@ impl Plugin for WinitPlugin { ), ); - app.add_plugin(AccessibilityPlugin); + app.add_plugins(AccessibilityPlugin); #[cfg(target_arch = "wasm32")] - app.add_plugin(CanvasParentResizePlugin); + app.add_plugins(CanvasParentResizePlugin); #[cfg(not(target_arch = "wasm32"))] let mut create_window_system_state: SystemState<( diff --git a/examples/2d/custom_gltf_vertex_attribute.rs b/examples/2d/custom_gltf_vertex_attribute.rs index 43356f04e4..c0dcd5d578 100644 --- a/examples/2d/custom_gltf_vertex_attribute.rs +++ b/examples/2d/custom_gltf_vertex_attribute.rs @@ -22,14 +22,14 @@ fn main() { color: Color::WHITE, brightness: 1.0 / 5.0f32, }) - .add_plugins( + .add_plugins(( DefaultPlugins.set( GltfPlugin::default() // Map a custom glTF attribute name to a `MeshVertexAttribute`. .add_custom_vertex_attribute("_BARYCENTRIC", ATTRIBUTE_BARYCENTRIC), ), - ) - .add_plugin(Material2dPlugin::::default()) + Material2dPlugin::::default(), + )) .add_systems(Startup, setup) .run(); } diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 0c55580d49..942d603483 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -32,8 +32,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(ColoredMesh2dPlugin) + .add_plugins((DefaultPlugins, ColoredMesh2dPlugin)) .add_systems(Startup, star) .run(); } diff --git a/examples/3d/anti_aliasing.rs b/examples/3d/anti_aliasing.rs index 8783d86635..a297858401 100644 --- a/examples/3d/anti_aliasing.rs +++ b/examples/3d/anti_aliasing.rs @@ -21,8 +21,7 @@ use bevy::{ fn main() { App::new() .insert_resource(Msaa::Off) - .add_plugins(DefaultPlugins) - .add_plugin(TemporalAntiAliasPlugin) + .add_plugins((DefaultPlugins, TemporalAntiAliasPlugin)) .add_systems(Startup, setup) .add_systems(Update, (modify_aa, modify_sharpening, update_ui)) .run(); diff --git a/examples/3d/lines.rs b/examples/3d/lines.rs index 0da72b3bd1..d94f0794b2 100644 --- a/examples/3d/lines.rs +++ b/examples/3d/lines.rs @@ -15,8 +15,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins((DefaultPlugins, MaterialPlugin::::default())) .add_systems(Startup, setup) .run(); } diff --git a/examples/3d/spotlight.rs b/examples/3d/spotlight.rs index 38ee6e11b5..96def528d7 100644 --- a/examples/3d/spotlight.rs +++ b/examples/3d/spotlight.rs @@ -9,9 +9,11 @@ use rand::{thread_rng, Rng}; fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + .add_plugins(( + DefaultPlugins, + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + )) .add_systems(Startup, setup) .add_systems(Update, (light_sway, movement)) .run(); diff --git a/examples/3d/ssao.rs b/examples/3d/ssao.rs index c95b71f45d..415741a8e5 100644 --- a/examples/3d/ssao.rs +++ b/examples/3d/ssao.rs @@ -17,8 +17,7 @@ fn main() { brightness: 5.0, ..default() }) - .add_plugins(DefaultPlugins) - .add_plugin(TemporalAntiAliasPlugin) + .add_plugins((DefaultPlugins, TemporalAntiAliasPlugin)) .add_systems(Startup, setup) .add_systems(Update, update) .run(); diff --git a/examples/3d/tonemapping.rs b/examples/3d/tonemapping.rs index 9ae3c84dc8..0bdceaae2e 100644 --- a/examples/3d/tonemapping.rs +++ b/examples/3d/tonemapping.rs @@ -19,8 +19,10 @@ use std::f32::consts::PI; fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins(( + DefaultPlugins, + MaterialPlugin::::default(), + )) .insert_resource(CameraTransform( Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), )) diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index f557469b19..277ab902a1 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -8,13 +8,15 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(RenderPlugin { - wgpu_settings: WgpuSettings { - features: WgpuFeatures::POLYGON_MODE_LINE, - ..default() - }, - })) - .add_plugin(WireframePlugin) + .add_plugins(( + DefaultPlugins.set(RenderPlugin { + wgpu_settings: WgpuSettings { + features: WgpuFeatures::POLYGON_MODE_LINE, + ..default() + }, + }), + WireframePlugin, + )) .add_systems(Startup, setup) .run(); } diff --git a/examples/app/plugin.rs b/examples/app/plugin.rs index f66fd6b842..93e22eada7 100644 --- a/examples/app/plugin.rs +++ b/examples/app/plugin.rs @@ -8,12 +8,14 @@ use bevy::{prelude::*, utils::Duration}; fn main() { App::new() - .add_plugins(DefaultPlugins) // plugins are registered as part of the "app building" process - .add_plugin(PrintMessagePlugin { - wait_duration: Duration::from_secs(1), - message: "This is an example plugin".to_string(), - }) + .add_plugins(( + DefaultPlugins, + PrintMessagePlugin { + wait_duration: Duration::from_secs(1), + message: "This is an example plugin".to_string(), + }, + )) .run(); } diff --git a/examples/app/plugin_group.rs b/examples/app/plugin_group.rs index ccd4f27698..cc35c48bbf 100644 --- a/examples/app/plugin_group.rs +++ b/examples/app/plugin_group.rs @@ -5,10 +5,12 @@ use bevy::{app::PluginGroupBuilder, prelude::*}; fn main() { App::new() - // Two PluginGroups that are included with bevy are DefaultPlugins and MinimalPlugins - .add_plugins(DefaultPlugins) - // Adding a plugin group adds all plugins in the group by default - .add_plugins(HelloWorldPlugins) + .add_plugins(( + // Two PluginGroups that are included with bevy are DefaultPlugins and MinimalPlugins + DefaultPlugins, + // Adding a plugin group adds all plugins in the group by default + HelloWorldPlugins, + )) // You can also modify a PluginGroup (such as disabling plugins) like this: // .add_plugins( // HelloWorldPlugins diff --git a/examples/diagnostics/custom_diagnostic.rs b/examples/diagnostics/custom_diagnostic.rs index 0be6363f15..60bf034292 100644 --- a/examples/diagnostics/custom_diagnostic.rs +++ b/examples/diagnostics/custom_diagnostic.rs @@ -7,10 +7,12 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - // The "print diagnostics" plugin is optional. - // It just visualizes our diagnostics in the console. - .add_plugin(LogDiagnosticsPlugin::default()) + .add_plugins(( + DefaultPlugins, + // The "print diagnostics" plugin is optional. + // It just visualizes our diagnostics in the console. + LogDiagnosticsPlugin::default(), + )) // Diagnostics must be initialized before measurements can be added. .register_diagnostic( Diagnostic::new(SYSTEM_ITERATION_COUNT, "system_iteration_count", 10) diff --git a/examples/diagnostics/log_diagnostics.rs b/examples/diagnostics/log_diagnostics.rs index 2cfb1e6cc8..e312ad671d 100644 --- a/examples/diagnostics/log_diagnostics.rs +++ b/examples/diagnostics/log_diagnostics.rs @@ -7,17 +7,18 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - // Adds frame time diagnostics - .add_plugin(FrameTimeDiagnosticsPlugin) - // Adds a system that prints diagnostics to the console - .add_plugin(LogDiagnosticsPlugin::default()) - // Any plugin can register diagnostics - // Uncomment this to add an entity count diagnostics: - // .add_plugin(bevy::diagnostic::EntityCountDiagnosticsPlugin::default()) - // Uncomment this to add an asset count diagnostics: - // .add_plugin(bevy::asset::diagnostic::AssetCountDiagnosticsPlugin::::default()) - // Uncomment this to add system info diagnostics: - // .add_plugin(bevy::diagnostic::SystemInformationDiagnosticsPlugin::default()) + .add_plugins(( + DefaultPlugins, + // Adds frame time diagnostics + FrameTimeDiagnosticsPlugin, + // Adds a system that prints diagnostics to the console + LogDiagnosticsPlugin::default(), + // Any plugin can register diagnostics. Uncomment this to add an entity count diagnostics: + // bevy::diagnostic::EntityCountDiagnosticsPlugin::default(), + // Uncomment this to add an asset count diagnostics: + // bevy::asset::diagnostic::AssetCountDiagnosticsPlugin::::default(), + // Uncomment this to add system info diagnostics: + // bevy::diagnostic::SystemInformationDiagnosticsPlugin::default() + )) .run(); } diff --git a/examples/ecs/ecs_guide.rs b/examples/ecs/ecs_guide.rs index 789e1b5131..a34871c744 100644 --- a/examples/ecs/ecs_guide.rs +++ b/examples/ecs/ecs_guide.rs @@ -256,7 +256,7 @@ fn main() { // Plugins are just a grouped set of app builder calls (just like we're doing here). // We could easily turn our game into a plugin, but you can check out the plugin example for // that :) The plugin below runs our app's "system schedule" once every 5 seconds. - .add_plugin(ScheduleRunnerPlugin::run_loop(Duration::from_secs(5))) + .add_plugins(ScheduleRunnerPlugin::run_loop(Duration::from_secs(5))) // `Startup` systems run exactly once BEFORE all other systems. These are generally used for // app initialization code (ex: adding entities and resources) .add_systems(Startup, startup_system) diff --git a/examples/ecs/system_closure.rs b/examples/ecs/system_closure.rs index 7c6c077f64..5049627293 100644 --- a/examples/ecs/system_closure.rs +++ b/examples/ecs/system_closure.rs @@ -25,7 +25,7 @@ fn main() { let outside_variable = "bar".to_string(); App::new() - .add_plugin(LogPlugin::default()) + .add_plugins(LogPlugin::default()) // we can use a closure as a system .add_systems(Update, simple_closure) // or we can use a more complex closure, and pass an argument to initialize a Local variable. diff --git a/examples/ecs/system_piping.rs b/examples/ecs/system_piping.rs index c3416c3994..f2584c46ad 100644 --- a/examples/ecs/system_piping.rs +++ b/examples/ecs/system_piping.rs @@ -11,7 +11,7 @@ fn main() { App::new() .insert_resource(Message("42".to_string())) .insert_resource(OptionalWarning(Err("Got to rusty?".to_string()))) - .add_plugin(LogPlugin { + .add_plugins(LogPlugin { level: Level::TRACE, filter: "".to_string(), }) diff --git a/examples/games/game_menu.rs b/examples/games/game_menu.rs index 3ecdf6ef21..08055514bd 100644 --- a/examples/games/game_menu.rs +++ b/examples/games/game_menu.rs @@ -37,9 +37,7 @@ fn main() { .add_state::() .add_systems(Startup, setup) // Adds the plugins for each state - .add_plugin(splash::SplashPlugin) - .add_plugin(menu::MenuPlugin) - .add_plugin(game::GamePlugin) + .add_plugins((splash::SplashPlugin, menu::MenuPlugin, game::GamePlugin)) .run(); } diff --git a/examples/shader/animate_shader.rs b/examples/shader/animate_shader.rs index 6821690323..e0cc03d2ee 100644 --- a/examples/shader/animate_shader.rs +++ b/examples/shader/animate_shader.rs @@ -9,8 +9,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins((DefaultPlugins, MaterialPlugin::::default())) .add_systems(Startup, setup) .run(); } diff --git a/examples/shader/array_texture.rs b/examples/shader/array_texture.rs index be32661f11..39e0b94a9a 100644 --- a/examples/shader/array_texture.rs +++ b/examples/shader/array_texture.rs @@ -9,8 +9,10 @@ use bevy::{ /// uniform variable. fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins(( + DefaultPlugins, + MaterialPlugin::::default(), + )) .add_systems(Startup, setup) .add_systems(Update, create_array_texture) .run(); diff --git a/examples/shader/compute_shader_game_of_life.rs b/examples/shader/compute_shader_game_of_life.rs index 47d5f75933..d737fb029c 100644 --- a/examples/shader/compute_shader_game_of_life.rs +++ b/examples/shader/compute_shader_game_of_life.rs @@ -23,15 +23,17 @@ const WORKGROUP_SIZE: u32 = 8; fn main() { App::new() .insert_resource(ClearColor(Color::BLACK)) - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - // uncomment for unthrottled FPS - // present_mode: bevy::window::PresentMode::AutoNoVsync, + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + // uncomment for unthrottled FPS + // present_mode: bevy::window::PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(GameOfLifeComputePlugin) + GameOfLifeComputePlugin, + )) .add_systems(Startup, setup) .run(); } @@ -70,7 +72,7 @@ impl Plugin for GameOfLifeComputePlugin { fn build(&self, app: &mut App) { // Extract the game of life image resource from the main world into the render world // for operation on by the compute shader and display on the sprite. - app.add_plugin(ExtractResourcePlugin::::default()); + app.add_plugins(ExtractResourcePlugin::::default()); let render_app = app.sub_app_mut(RenderApp); render_app.add_systems(Render, queue_bind_group.in_set(RenderSet::Queue)); diff --git a/examples/shader/custom_vertex_attribute.rs b/examples/shader/custom_vertex_attribute.rs index 010701d28d..aaca77df96 100644 --- a/examples/shader/custom_vertex_attribute.rs +++ b/examples/shader/custom_vertex_attribute.rs @@ -15,8 +15,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins((DefaultPlugins, MaterialPlugin::::default())) .add_systems(Startup, setup) .run(); } diff --git a/examples/shader/fallback_image.rs b/examples/shader/fallback_image.rs index a3762b9fd0..7119324216 100644 --- a/examples/shader/fallback_image.rs +++ b/examples/shader/fallback_image.rs @@ -13,8 +13,10 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins(( + DefaultPlugins, + MaterialPlugin::::default(), + )) .add_systems(Startup, setup) .run(); } diff --git a/examples/shader/post_processing.rs b/examples/shader/post_processing.rs index 1480e69917..4705193770 100644 --- a/examples/shader/post_processing.rs +++ b/examples/shader/post_processing.rs @@ -35,12 +35,14 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(AssetPlugin { - // Hot reloading the shader works correctly - watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)), - ..default() - })) - .add_plugin(PostProcessPlugin) + .add_plugins(( + DefaultPlugins.set(AssetPlugin { + // Hot reloading the shader works correctly + watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)), + ..default() + }), + PostProcessPlugin, + )) .add_systems(Startup, setup) .add_systems(Update, (rotate, update_settings)) .run(); @@ -51,18 +53,19 @@ struct PostProcessPlugin; impl Plugin for PostProcessPlugin { fn build(&self, app: &mut App) { - app + app.add_plugins(( // The settings will be a component that lives in the main world but will // be extracted to the render world every frame. // This makes it possible to control the effect from the main world. // This plugin will take care of extracting it automatically. // It's important to derive [`ExtractComponent`] on [`PostProcessingSettings`] // for this plugin to work correctly. - .add_plugin(ExtractComponentPlugin::::default()) + ExtractComponentPlugin::::default(), // The settings will also be the data used in the shader. // This plugin will prepare the component for the GPU by creating a uniform buffer // and writing the data to that buffer every frame. - .add_plugin(UniformComponentPlugin::::default()); + UniformComponentPlugin::::default(), + )); // We need to get the render app from the main app let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { diff --git a/examples/shader/shader_defs.rs b/examples/shader/shader_defs.rs index a3ad6e30b7..1f45c43155 100644 --- a/examples/shader/shader_defs.rs +++ b/examples/shader/shader_defs.rs @@ -14,8 +14,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins((DefaultPlugins, MaterialPlugin::::default())) .add_systems(Startup, setup) .run(); } diff --git a/examples/shader/shader_instancing.rs b/examples/shader/shader_instancing.rs index a470ae62f0..a1cbde6d18 100644 --- a/examples/shader/shader_instancing.rs +++ b/examples/shader/shader_instancing.rs @@ -26,8 +26,7 @@ use bytemuck::{Pod, Zeroable}; fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(CustomMaterialPlugin) + .add_plugins((DefaultPlugins, CustomMaterialPlugin)) .add_systems(Startup, setup) .run(); } @@ -80,7 +79,7 @@ pub struct CustomMaterialPlugin; impl Plugin for CustomMaterialPlugin { fn build(&self, app: &mut App) { - app.add_plugin(ExtractComponentPlugin::::default()); + app.add_plugins(ExtractComponentPlugin::::default()); app.sub_app_mut(RenderApp) .add_render_command::() .init_resource::>() diff --git a/examples/shader/shader_material.rs b/examples/shader/shader_material.rs index ac321d8ebc..6e5148d0ec 100644 --- a/examples/shader/shader_material.rs +++ b/examples/shader/shader_material.rs @@ -8,8 +8,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins((DefaultPlugins, MaterialPlugin::::default())) .add_systems(Startup, setup) .run(); } diff --git a/examples/shader/shader_material_glsl.rs b/examples/shader/shader_material_glsl.rs index 7182cf439a..5d33f47058 100644 --- a/examples/shader/shader_material_glsl.rs +++ b/examples/shader/shader_material_glsl.rs @@ -14,8 +14,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins((DefaultPlugins, MaterialPlugin::::default())) .add_systems(Startup, setup) .run(); } diff --git a/examples/shader/shader_material_screenspace_texture.rs b/examples/shader/shader_material_screenspace_texture.rs index bace5855fb..b0ec22368e 100644 --- a/examples/shader/shader_material_screenspace_texture.rs +++ b/examples/shader/shader_material_screenspace_texture.rs @@ -8,8 +8,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(MaterialPlugin::::default()) + .add_plugins((DefaultPlugins, MaterialPlugin::::default())) .add_systems(Startup, setup) .add_systems(Update, rotate_camera) .run(); diff --git a/examples/shader/shader_prepass.rs b/examples/shader/shader_prepass.rs index 6d77162839..81bc4dc449 100644 --- a/examples/shader/shader_prepass.rs +++ b/examples/shader/shader_prepass.rs @@ -12,20 +12,22 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(PbrPlugin { - // The prepass is enabled by default on the StandardMaterial, - // but you can disable it if you need to. - // - // prepass_enabled: false, - ..default() - })) - .add_plugin(MaterialPlugin::::default()) - .add_plugin(MaterialPlugin:: { - // This material only needs to read the prepass textures, - // but the meshes using it should not contribute to the prepass render, so we can disable it. - prepass_enabled: false, - ..default() - }) + .add_plugins(( + DefaultPlugins.set(PbrPlugin { + // The prepass is enabled by default on the StandardMaterial, + // but you can disable it if you need to. + // + // prepass_enabled: false, + ..default() + }), + MaterialPlugin::::default(), + MaterialPlugin:: { + // This material only needs to read the prepass textures, + // but the meshes using it should not contribute to the prepass render, so we can disable it. + prepass_enabled: false, + ..default() + }, + )) .add_systems(Startup, setup) .add_systems(Update, (rotate, toggle_prepass_view)) // Disabling MSAA for maximum compatibility. Shader prepass with MSAA needs GPU capability MULTISAMPLED_SHADING diff --git a/examples/shader/texture_binding_array.rs b/examples/shader/texture_binding_array.rs index 76c1c13e48..c4affd57c1 100644 --- a/examples/shader/texture_binding_array.rs +++ b/examples/shader/texture_binding_array.rs @@ -16,12 +16,13 @@ use std::{num::NonZeroU32, process::exit}; fn main() { let mut app = App::new(); - app.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())); - - app.add_plugin(GpuFeatureSupportChecker) - .add_plugin(MaterialPlugin::::default()) - .add_systems(Startup, setup) - .run(); + app.add_plugins(( + DefaultPlugins.set(ImagePlugin::default_nearest()), + GpuFeatureSupportChecker, + MaterialPlugin::::default(), + )) + .add_systems(Startup, setup) + .run(); } const MAX_TEXTURE_COUNT: usize = 16; diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index 98065724d8..d9cbe76a89 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -28,17 +28,19 @@ struct Bird { fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "BevyMark".into(), - resolution: (800., 600.).into(), - present_mode: PresentMode::AutoNoVsync, + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + title: "BevyMark".into(), + resolution: (800., 600.).into(), + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + )) .insert_resource(BevyCounter { count: 0, color: Color::WHITE, diff --git a/examples/stress_tests/many_animated_sprites.rs b/examples/stress_tests/many_animated_sprites.rs index a5dd281de7..6647447d6f 100644 --- a/examples/stress_tests/many_animated_sprites.rs +++ b/examples/stress_tests/many_animated_sprites.rs @@ -20,15 +20,17 @@ const CAMERA_SPEED: f32 = 1000.0; fn main() { App::new() // Since this is also used as a benchmark, we want it to display performance data. - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - present_mode: PresentMode::AutoNoVsync, + .add_plugins(( + LogDiagnosticsPlugin::default(), + FrameTimeDiagnosticsPlugin, + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) + )) .add_systems(Startup, setup) .add_systems( Update, diff --git a/examples/stress_tests/many_buttons.rs b/examples/stress_tests/many_buttons.rs index 19d424a1df..28846a7f1e 100644 --- a/examples/stress_tests/many_buttons.rs +++ b/examples/stress_tests/many_buttons.rs @@ -23,15 +23,17 @@ const FONT_SIZE: f32 = 7.0; fn main() { let mut app = App::new(); - app.add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - present_mode: PresentMode::AutoNoVsync, + app.add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + )) .add_systems(Startup, setup) .add_systems(Update, button_system); diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index dc20c4fa36..20495b1ab7 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -21,15 +21,17 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - present_mode: PresentMode::AutoNoVsync, + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + )) .add_systems(Startup, setup) .add_systems(Update, (move_camera, print_mesh_count)) .run(); diff --git a/examples/stress_tests/many_foxes.rs b/examples/stress_tests/many_foxes.rs index 9244861d8b..18dee869bc 100644 --- a/examples/stress_tests/many_foxes.rs +++ b/examples/stress_tests/many_foxes.rs @@ -20,16 +20,18 @@ struct Foxes { fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "🦊🦊🦊 Many Foxes! 🦊🦊🦊".into(), - present_mode: PresentMode::AutoNoVsync, + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + title: "🦊🦊🦊 Many Foxes! 🦊🦊🦊".into(), + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + )) .insert_resource(Foxes { count: std::env::args() .nth(1) diff --git a/examples/stress_tests/many_gizmos.rs b/examples/stress_tests/many_gizmos.rs index 1feb390408..472b25d5e4 100644 --- a/examples/stress_tests/many_gizmos.rs +++ b/examples/stress_tests/many_gizmos.rs @@ -10,15 +10,17 @@ const SYSTEM_COUNT: u32 = 10; fn main() { let mut app = App::new(); - app.add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "Many Debug Lines".to_string(), - present_mode: PresentMode::AutoNoVsync, + app.add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + title: "Many Debug Lines".to_string(), + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) + FrameTimeDiagnosticsPlugin, + )) .insert_resource(Config { line_count: 50_000, fancy: false, diff --git a/examples/stress_tests/many_glyphs.rs b/examples/stress_tests/many_glyphs.rs index 77127b57ca..7e5899a7c2 100644 --- a/examples/stress_tests/many_glyphs.rs +++ b/examples/stress_tests/many_glyphs.rs @@ -14,15 +14,17 @@ use bevy::{ fn main() { let mut app = App::new(); - app.add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - present_mode: PresentMode::AutoNoVsync, + app.add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + present_mode: PresentMode::Immediate, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + )) .add_systems(Startup, setup); if std::env::args().any(|arg| arg == "recompute-text") { diff --git a/examples/stress_tests/many_lights.rs b/examples/stress_tests/many_lights.rs index bf81668536..66fe81ef43 100644 --- a/examples/stress_tests/many_lights.rs +++ b/examples/stress_tests/many_lights.rs @@ -15,20 +15,22 @@ use rand::{thread_rng, Rng}; fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - resolution: (1024.0, 768.0).into(), - title: "many_lights".into(), - present_mode: PresentMode::AutoNoVsync, + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + resolution: (1024.0, 768.0).into(), + title: "many_lights".into(), + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + LogVisibleLights, + )) .add_systems(Startup, setup) .add_systems(Update, (move_camera, print_light_count)) - .add_plugin(LogVisibleLights) .run(); } diff --git a/examples/stress_tests/many_sprites.rs b/examples/stress_tests/many_sprites.rs index 87776ef61e..d95cdf4e58 100644 --- a/examples/stress_tests/many_sprites.rs +++ b/examples/stress_tests/many_sprites.rs @@ -28,15 +28,17 @@ fn main() { std::env::args().nth(1).unwrap_or_default() == "--colored", )) // Since this is also used as a benchmark, we want it to display performance data. - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - present_mode: PresentMode::AutoNoVsync, + .add_plugins(( + LogDiagnosticsPlugin::default(), + FrameTimeDiagnosticsPlugin, + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) + )) .add_systems(Startup, setup) .add_systems( Update, diff --git a/examples/stress_tests/text_pipeline.rs b/examples/stress_tests/text_pipeline.rs index 64ffe57ae7..cd0e77a9b1 100644 --- a/examples/stress_tests/text_pipeline.rs +++ b/examples/stress_tests/text_pipeline.rs @@ -11,15 +11,17 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - present_mode: PresentMode::Immediate, + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + present_mode: PresentMode::Immediate, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) - .add_plugin(LogDiagnosticsPlugin::default()) + FrameTimeDiagnosticsPlugin, + LogDiagnosticsPlugin::default(), + )) .add_systems(Startup, spawn) .add_systems(Update, update_text_bounds) .run(); diff --git a/examples/stress_tests/transform_hierarchy.rs b/examples/stress_tests/transform_hierarchy.rs index 18562fcd0d..4f294c077b 100644 --- a/examples/stress_tests/transform_hierarchy.rs +++ b/examples/stress_tests/transform_hierarchy.rs @@ -183,8 +183,7 @@ fn main() { App::new() .insert_resource(cfg) - .add_plugins(MinimalPlugins) - .add_plugin(TransformPlugin) + .add_plugins((MinimalPlugins, TransformPlugin)) .add_systems(Startup, setup) // Updating transforms *must* be done before `CoreSet::PostUpdate` // or the hierarchy will momentarily be in an invalid state. diff --git a/examples/tools/scene_viewer/main.rs b/examples/tools/scene_viewer/main.rs index 1295d7d809..ab20505bf8 100644 --- a/examples/tools/scene_viewer/main.rs +++ b/examples/tools/scene_viewer/main.rs @@ -26,7 +26,7 @@ fn main() { color: Color::WHITE, brightness: 1.0 / 5.0f32, }) - .add_plugins( + .add_plugins(( DefaultPlugins .set(WindowPlugin { primary_window: Some(Window { @@ -40,9 +40,9 @@ fn main() { .unwrap_or_else(|_| ".".to_string()), watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)), }), - ) - .add_plugin(CameraControllerPlugin) - .add_plugin(SceneViewerPlugin) + CameraControllerPlugin, + SceneViewerPlugin, + )) .add_systems(Startup, setup) .add_systems(PreUpdate, setup_scene_after_load); diff --git a/examples/ui/text.rs b/examples/ui/text.rs index 841358c2bd..ccc44f5095 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -10,8 +10,7 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins) - .add_plugin(FrameTimeDiagnosticsPlugin) + .add_plugins((DefaultPlugins, FrameTimeDiagnosticsPlugin)) .add_systems(Startup, setup) .add_systems(Update, (text_update_system, text_color_system)) .run(); diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index e1756d3792..cfacced41c 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -8,14 +8,16 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - present_mode: PresentMode::AutoNoVsync, + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + present_mode: PresentMode::AutoNoVsync, + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(FrameTimeDiagnosticsPlugin) + FrameTimeDiagnosticsPlugin, + )) .add_systems(Startup, infotext_system) .add_systems(Update, change_text_system) .run(); diff --git a/examples/window/window_settings.rs b/examples/window/window_settings.rs index 6bbb48aa25..158c1d9b78 100644 --- a/examples/window/window_settings.rs +++ b/examples/window/window_settings.rs @@ -9,22 +9,24 @@ use bevy::{ fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "I am a window!".into(), - resolution: (500., 300.).into(), - present_mode: PresentMode::AutoVsync, - // Tells wasm to resize the window according to the available canvas - fit_canvas_to_parent: true, - // Tells wasm not to override default event handling, like F5, Ctrl+R etc. - prevent_default_event_handling: false, - window_theme: Some(WindowTheme::Dark), + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + title: "I am a window!".into(), + resolution: (500., 300.).into(), + present_mode: PresentMode::AutoVsync, + // Tells wasm to resize the window according to the available canvas + fit_canvas_to_parent: true, + // Tells wasm not to override default event handling, like F5, Ctrl+R etc. + prevent_default_event_handling: false, + window_theme: Some(WindowTheme::Dark), + ..default() + }), ..default() }), - ..default() - })) - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin) + LogDiagnosticsPlugin::default(), + FrameTimeDiagnosticsPlugin, + )) .add_systems( Update, (