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