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