bevy_internal/
default_plugins.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
use bevy_app::{plugin_group, Plugin};

plugin_group! {
    /// This plugin group will add all the default plugins for a *Bevy* application:
    pub struct DefaultPlugins {
        bevy_app:::PanicHandlerPlugin,
        #[cfg(feature = "bevy_log")]
        bevy_log:::LogPlugin,
        bevy_app:::TaskPoolPlugin,
        bevy_diagnostic:::FrameCountPlugin,
        bevy_time:::TimePlugin,
        bevy_transform:::TransformPlugin,
        bevy_diagnostic:::DiagnosticsPlugin,
        bevy_input:::InputPlugin,
        #[custom(cfg(not(feature = "bevy_window")))]
        bevy_app:::ScheduleRunnerPlugin,
        #[cfg(feature = "bevy_window")]
        bevy_window:::WindowPlugin,
        #[cfg(feature = "bevy_window")]
        bevy_a11y:::AccessibilityPlugin,
        #[cfg(feature = "std")]
        #[custom(cfg(any(unix, windows)))]
        bevy_app:::TerminalCtrlCHandlerPlugin,
        #[cfg(feature = "bevy_asset")]
        bevy_asset:::AssetPlugin,
        #[cfg(feature = "bevy_scene")]
        bevy_scene:::ScenePlugin,
        #[cfg(feature = "bevy_winit")]
        bevy_winit:::WinitPlugin,
        #[cfg(feature = "bevy_render")]
        bevy_render:::RenderPlugin,
        // NOTE: Load this after renderer initialization so that it knows about the supported
        // compressed texture formats.
        #[cfg(feature = "bevy_render")]
        bevy_render::texture:::ImagePlugin,
        #[cfg(feature = "bevy_render")]
        #[custom(cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded")))]
        bevy_render::pipelined_rendering:::PipelinedRenderingPlugin,
        #[cfg(feature = "bevy_core_pipeline")]
        bevy_core_pipeline:::CorePipelinePlugin,
        #[cfg(feature = "bevy_sprite")]
        bevy_sprite:::SpritePlugin,
        #[cfg(feature = "bevy_text")]
        bevy_text:::TextPlugin,
        #[cfg(feature = "bevy_ui")]
        bevy_ui:::UiPlugin,
        #[cfg(feature = "bevy_pbr")]
        bevy_pbr:::PbrPlugin,
        // NOTE: Load this after renderer initialization so that it knows about the supported
        // compressed texture formats.
        #[cfg(feature = "bevy_gltf")]
        bevy_gltf:::GltfPlugin,
        #[cfg(feature = "bevy_audio")]
        bevy_audio:::AudioPlugin,
        #[cfg(feature = "bevy_gilrs")]
        bevy_gilrs:::GilrsPlugin,
        #[cfg(feature = "bevy_animation")]
        bevy_animation:::AnimationPlugin,
        #[cfg(feature = "bevy_gizmos")]
        bevy_gizmos:::GizmoPlugin,
        #[cfg(feature = "bevy_state")]
        bevy_state::app:::StatesPlugin,
        #[cfg(feature = "bevy_dev_tools")]
        bevy_dev_tools:::DevToolsPlugin,
        #[cfg(feature = "bevy_ci_testing")]
        bevy_dev_tools::ci_testing:::CiTestingPlugin,
        #[plugin_group]
        #[cfg(feature = "bevy_picking")]
        bevy_picking:::DefaultPickingPlugins,
        #[doc(hidden)]
        :IgnoreAmbiguitiesPlugin,
    }
    /// [`DefaultPlugins`] obeys *Cargo* *feature* flags. Users may exert control over this plugin group
    /// by disabling `default-features` in their `Cargo.toml` and enabling only those features
    /// that they wish to use.
    ///
    /// [`DefaultPlugins`] contains all the plugins typically required to build
    /// a *Bevy* application which includes a *window* and presentation components.
    /// For the absolute minimum number of plugins needed to run a Bevy application, see [`MinimalPlugins`].
}

#[derive(Default)]
struct IgnoreAmbiguitiesPlugin;

impl Plugin for IgnoreAmbiguitiesPlugin {
    #[expect(
        clippy::allow_attributes,
        reason = "`unused_variables` is not always linted"
    )]
    #[allow(
        unused_variables,
        reason = "The `app` parameter is used only if a combination of crates that contain ambiguities with each other are enabled."
    )]
    fn build(&self, app: &mut bevy_app::App) {
        // bevy_ui owns the Transform and cannot be animated
        #[cfg(all(feature = "bevy_animation", feature = "bevy_ui"))]
        if app.is_plugin_added::<bevy_animation::AnimationPlugin>()
            && app.is_plugin_added::<bevy_ui::UiPlugin>()
        {
            app.ignore_ambiguity(
                bevy_app::PostUpdate,
                bevy_animation::advance_animations,
                bevy_ui::ui_layout_system,
            );
            app.ignore_ambiguity(
                bevy_app::PostUpdate,
                bevy_animation::animate_targets,
                bevy_ui::ui_layout_system,
            );
        }
    }
}

plugin_group! {
    /// This plugin group will add the minimal plugins for a *Bevy* application:
    pub struct MinimalPlugins {
        bevy_app:::TaskPoolPlugin,
        bevy_diagnostic:::FrameCountPlugin,
        bevy_time:::TimePlugin,
        bevy_app:::ScheduleRunnerPlugin,
        #[cfg(feature = "bevy_ci_testing")]
        bevy_dev_tools::ci_testing:::CiTestingPlugin,
    }
    /// This plugin group represents the absolute minimum, bare-bones, bevy application.
    /// Use this if you want to have absolute control over the plugins used.
    ///
    /// It includes a [schedule runner (`ScheduleRunnerPlugin`)](crate::app::ScheduleRunnerPlugin)
    /// to provide functionality that would otherwise be driven by a windowed application's
    /// *event loop* or *message loop*.
    ///
    /// By default, this loop will run as fast as possible, which can result in high CPU usage.
    /// You can add a delay using [`run_loop`](crate::app::ScheduleRunnerPlugin::run_loop),
    /// or remove the loop using [`run_once`](crate::app::ScheduleRunnerPlugin::run_once).
    /// # Example:
    /// ```rust, no_run
    /// # use std::time::Duration;
    /// # use bevy_app::{App, PluginGroup, ScheduleRunnerPlugin};
    /// # use bevy_internal::MinimalPlugins;
    /// App::new().add_plugins(MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(
    ///     // Run 60 times per second.
    ///     Duration::from_secs_f64(1.0 / 60.0),
    /// ))).run();
}