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