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        bevy_log:::LogPlugin,
8        bevy_core:::TaskPoolPlugin,
9        bevy_core:::TypeRegistrationPlugin,
10        bevy_core:::FrameCountPlugin,
11        bevy_time:::TimePlugin,
12        bevy_transform:::TransformPlugin,
13        bevy_hierarchy:::HierarchyPlugin,
14        bevy_diagnostic:::DiagnosticsPlugin,
15        bevy_input:::InputPlugin,
16        #[custom(cfg(not(feature = "bevy_window")))]
17        bevy_app:::ScheduleRunnerPlugin,
18        #[cfg(feature = "bevy_window")]
19        bevy_window:::WindowPlugin,
20        #[cfg(feature = "bevy_window")]
21        bevy_a11y:::AccessibilityPlugin,
22        #[custom(cfg(not(target_arch = "wasm32")))]
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    #[allow(unused_variables)] // Variables are used depending on enabled features
87    fn build(&self, app: &mut bevy_app::App) {
88        // bevy_ui owns the Transform and cannot be animated
89        #[cfg(all(feature = "bevy_animation", feature = "bevy_ui"))]
90        if app.is_plugin_added::<bevy_animation::AnimationPlugin>()
91            && app.is_plugin_added::<bevy_ui::UiPlugin>()
92        {
93            app.ignore_ambiguity(
94                bevy_app::PostUpdate,
95                bevy_animation::advance_animations,
96                bevy_ui::ui_layout_system,
97            );
98            app.ignore_ambiguity(
99                bevy_app::PostUpdate,
100                bevy_animation::animate_targets,
101                bevy_ui::ui_layout_system,
102            );
103        }
104    }
105}
106
107plugin_group! {
108    /// This plugin group will add the minimal plugins for a *Bevy* application:
109    pub struct MinimalPlugins {
110        bevy_core:::TaskPoolPlugin,
111        bevy_core:::TypeRegistrationPlugin,
112        bevy_core:::FrameCountPlugin,
113        bevy_time:::TimePlugin,
114        bevy_app:::ScheduleRunnerPlugin,
115        #[cfg(feature = "bevy_ci_testing")]
116        bevy_dev_tools::ci_testing:::CiTestingPlugin,
117    }
118    /// This plugin group represents the absolute minimum, bare-bones, bevy application.
119    /// Use this if you want to have absolute control over the plugins used.
120    ///
121    /// It includes a [schedule runner (`ScheduleRunnerPlugin`)](crate::app::ScheduleRunnerPlugin)
122    /// to provide functionality that would otherwise be driven by a windowed application's
123    /// *event loop* or *message loop*.
124}