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