bevy_internal/
default_plugins.rs

1use bevy_app::{plugin_group, Plugin};
2
3plugin_group! {
4    /// This plugin group will add all the default plugins for a *Bevy* application:
5    pub struct DefaultPlugins {
6        bevy_app:::PanicHandlerPlugin,
7        #[cfg(feature = "bevy_log")]
8        bevy_log:::LogPlugin,
9        bevy_app:::TaskPoolPlugin,
10        bevy_diagnostic:::FrameCountPlugin,
11        bevy_time:::TimePlugin,
12        bevy_transform:::TransformPlugin,
13        bevy_diagnostic:::DiagnosticsPlugin,
14        bevy_input:::InputPlugin,
15        #[custom(cfg(not(feature = "bevy_window")))]
16        bevy_app:::ScheduleRunnerPlugin,
17        #[cfg(feature = "bevy_window")]
18        bevy_window:::WindowPlugin,
19        #[cfg(feature = "bevy_window")]
20        bevy_a11y:::AccessibilityPlugin,
21        #[cfg(feature = "std")]
22        #[custom(cfg(any(all(unix, not(target_os = "horizon")), windows)))]
23        bevy_app:::TerminalCtrlCHandlerPlugin,
24        // NOTE: Load this before AssetPlugin to properly register http asset sources.
25        #[cfg(feature = "bevy_asset")]
26        #[custom(cfg(any(feature = "http", feature = "https")))]
27        bevy_asset::io::web:::WebAssetPlugin,
28        #[cfg(feature = "bevy_asset")]
29        bevy_asset:::AssetPlugin,
30        #[cfg(feature = "bevy_scene")]
31        bevy_scene:::ScenePlugin,
32        #[cfg(feature = "bevy_winit")]
33        bevy_winit:::WinitPlugin,
34        #[custom(cfg(all(feature = "dlss", not(feature = "force_disable_dlss"))))]
35        bevy_anti_alias::dlss:::DlssInitPlugin,
36        #[cfg(feature = "bevy_render")]
37        bevy_render:::RenderPlugin,
38        // NOTE: Load this after renderer initialization so that it knows about the supported
39        // compressed texture formats.
40        #[cfg(feature = "bevy_image")]
41        bevy_image:::ImagePlugin,
42        #[cfg(feature = "bevy_mesh")]
43        bevy_mesh:::MeshPlugin,
44        #[cfg(feature = "bevy_camera")]
45        bevy_camera:::CameraPlugin,
46        #[cfg(feature = "bevy_light")]
47        bevy_light:::LightPlugin,
48        #[cfg(feature = "bevy_render")]
49        #[custom(cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded")))]
50        bevy_render::pipelined_rendering:::PipelinedRenderingPlugin,
51        #[cfg(feature = "bevy_core_pipeline")]
52        bevy_core_pipeline:::CorePipelinePlugin,
53        #[cfg(feature = "bevy_post_process")]
54        bevy_post_process:::PostProcessPlugin,
55        #[cfg(feature = "bevy_anti_alias")]
56        bevy_anti_alias:::AntiAliasPlugin,
57        #[cfg(feature = "bevy_sprite")]
58        bevy_sprite:::SpritePlugin,
59        #[cfg(feature = "bevy_sprite_render")]
60        bevy_sprite_render:::SpriteRenderPlugin,
61        #[cfg(feature = "bevy_text")]
62        bevy_text:::TextPlugin,
63        #[cfg(feature = "bevy_ui")]
64        bevy_ui:::UiPlugin,
65        #[cfg(feature = "bevy_ui_render")]
66        bevy_ui_render:::UiRenderPlugin,
67        #[cfg(feature = "bevy_pbr")]
68        bevy_pbr:::PbrPlugin,
69        // NOTE: Load this after renderer initialization so that it knows about the supported
70        // compressed texture formats.
71        #[cfg(feature = "bevy_gltf")]
72        bevy_gltf:::GltfPlugin,
73        #[cfg(feature = "bevy_audio")]
74        bevy_audio:::AudioPlugin,
75        #[cfg(feature = "bevy_gilrs")]
76        bevy_gilrs:::GilrsPlugin,
77        #[cfg(feature = "bevy_animation")]
78        bevy_animation:::AnimationPlugin,
79        #[cfg(feature = "bevy_gizmos")]
80        bevy_gizmos:::GizmoPlugin,
81        #[cfg(feature = "bevy_state")]
82        bevy_state::app:::StatesPlugin,
83        #[cfg(feature = "bevy_dev_tools")]
84        bevy_dev_tools:::DevToolsPlugin,
85        #[cfg(feature = "bevy_ci_testing")]
86        bevy_dev_tools::ci_testing:::CiTestingPlugin,
87        #[cfg(feature = "hotpatching")]
88        bevy_app::hotpatch:::HotPatchPlugin,
89        #[plugin_group]
90        #[cfg(feature = "bevy_picking")]
91        bevy_picking:::DefaultPickingPlugins,
92        #[doc(hidden)]
93        :IgnoreAmbiguitiesPlugin,
94    }
95    /// [`DefaultPlugins`] obeys *Cargo* *feature* flags. Users may exert control over this plugin group
96    /// by disabling `default-features` in their `Cargo.toml` and enabling only those features
97    /// that they wish to use.
98    ///
99    /// [`DefaultPlugins`] contains all the plugins typically required to build
100    /// a *Bevy* application which includes a *window* and presentation components.
101    /// For the absolute minimum number of plugins needed to run a Bevy application, see [`MinimalPlugins`].
102}
103
104#[derive(Default)]
105struct IgnoreAmbiguitiesPlugin;
106
107impl Plugin for IgnoreAmbiguitiesPlugin {
108    #[expect(
109        clippy::allow_attributes,
110        reason = "`unused_variables` is not always linted"
111    )]
112    #[allow(
113        unused_variables,
114        reason = "The `app` parameter is used only if a combination of crates that contain ambiguities with each other are enabled."
115    )]
116    fn build(&self, app: &mut bevy_app::App) {
117        // bevy_ui owns the Transform and cannot be animated
118        #[cfg(all(feature = "bevy_animation", feature = "bevy_ui"))]
119        if app.is_plugin_added::<bevy_animation::AnimationPlugin>()
120            && app.is_plugin_added::<bevy_ui::UiPlugin>()
121        {
122            app.ignore_ambiguity(
123                bevy_app::PostUpdate,
124                bevy_animation::advance_animations,
125                bevy_ui::ui_layout_system,
126            );
127            app.ignore_ambiguity(
128                bevy_app::PostUpdate,
129                bevy_animation::animate_targets,
130                bevy_ui::ui_layout_system,
131            );
132        }
133    }
134}
135
136plugin_group! {
137    /// This plugin group will add the minimal plugins for a *Bevy* application:
138    pub struct MinimalPlugins {
139        bevy_app:::TaskPoolPlugin,
140        bevy_diagnostic:::FrameCountPlugin,
141        bevy_time:::TimePlugin,
142        bevy_app:::ScheduleRunnerPlugin,
143        #[cfg(feature = "bevy_ci_testing")]
144        bevy_dev_tools::ci_testing:::CiTestingPlugin,
145    }
146    /// This plugin group represents the absolute minimum, bare-bones, bevy application.
147    /// Use this if you want to have absolute control over the plugins used.
148    ///
149    /// It includes a [schedule runner (`ScheduleRunnerPlugin`)](crate::app::ScheduleRunnerPlugin)
150    /// to provide functionality that would otherwise be driven by a windowed application's
151    /// *event loop* or *message loop*.
152    ///
153    /// By default, this loop will run as fast as possible, which can result in high CPU usage.
154    /// You can add a delay using [`run_loop`](crate::app::ScheduleRunnerPlugin::run_loop),
155    /// or remove the loop using [`run_once`](crate::app::ScheduleRunnerPlugin::run_once).
156    /// # Example:
157    /// ```rust, no_run
158    /// # use std::time::Duration;
159    /// # use bevy_app::{App, PluginGroup, ScheduleRunnerPlugin};
160    /// # use bevy_internal::MinimalPlugins;
161    /// App::new().add_plugins(MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(
162    ///     // Run 60 times per second.
163    ///     Duration::from_secs_f64(1.0 / 60.0),
164    /// ))).run();
165}