mirror of
https://github.com/bevyengine/bevy
synced 2025-01-07 02:38:59 +00:00
c3057d4353
# Objective - Adopted from #11460. - Closes #7332. - The documentation for `DefaultPlugins` and `MinimalPlugins` frequently goes out of date because it is not . ## Solution - Create a macro, `plugin_group!`, to automatically create `PluginGroup`s and document them. ## Testing - Run `cargo-expand` on the generated code for `DefaultPlugins` and `MinimalPlugins`. - Try creating a custom plugin group with the macro. --- ## Showcase - You can now define custom `PluginGroup`s using the `plugin_group!` macro. ```rust plugin_group! { /// My really cool plugic group! pub struct MyPluginGroup { physics:::PhysicsPlugin, rendering:::RenderingPlugin, ui:::UiPlugin, } } ``` <details> <summary>Expanded output</summary> ```rust /// My really cool plugic group! /// /// - [`PhysicsPlugin`](physics::PhysicsPlugin) /// - [`RenderingPlugin`](rendering::RenderingPlugin) /// - [`UiPlugin`](ui::UiPlugin) pub struct MyPluginGroup; impl ::bevy_app::PluginGroup for MyPluginGroup { fn build(self) -> ::bevy_app::PluginGroupBuilder { let mut group = ::bevy_app::PluginGroupBuilder::start::<Self>(); { const _: () = { const fn check_default<T: Default>() {} check_default::<physics::PhysicsPlugin>(); }; group = group.add(<physics::PhysicsPlugin>::default()); } { const _: () = { const fn check_default<T: Default>() {} check_default::<rendering::RenderingPlugin>(); }; group = group.add(<rendering::RenderingPlugin>::default()); } { const _: () = { const fn check_default<T: Default>() {} check_default::<ui::UiPlugin>(); }; group = group.add(<ui::UiPlugin>::default()); } group } } ``` </details> --------- Co-authored-by: Doonv <58695417+doonv@users.noreply.github.com> Co-authored-by: Mateusz Wachowiak <mateusz_wachowiak@outlook.com>
55 lines
1.7 KiB
Rust
55 lines
1.7 KiB
Rust
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
|
#![forbid(unsafe_code)]
|
|
#![doc(
|
|
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
|
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
|
)]
|
|
|
|
//! This crate provides additional utilities for the [Bevy game engine](https://bevyengine.org),
|
|
//! focused on improving developer experience.
|
|
|
|
use bevy_app::prelude::*;
|
|
|
|
#[cfg(feature = "bevy_ci_testing")]
|
|
pub mod ci_testing;
|
|
|
|
pub mod fps_overlay;
|
|
|
|
#[cfg(feature = "bevy_ui_debug")]
|
|
pub mod ui_debug_overlay;
|
|
|
|
pub mod states;
|
|
|
|
/// Enables developer tools in an [`App`]. This plugin is added automatically with `bevy_dev_tools`
|
|
/// feature.
|
|
///
|
|
/// Warning: It is not recommended to enable this in final shipped games or applications.
|
|
/// Dev tools provide a high level of access to the internals of your application,
|
|
/// and may interfere with ordinary use and gameplay.
|
|
///
|
|
/// To enable developer tools, you can either:
|
|
///
|
|
/// - Create a custom crate feature (e.g "`dev_mode`"), which enables the `bevy_dev_tools` feature
|
|
/// along with any other development tools you might be using:
|
|
///
|
|
/// ```toml
|
|
/// [feature]
|
|
/// dev_mode = ["bevy/bevy_dev_tools", "other_dev_tools"]
|
|
/// ```
|
|
///
|
|
/// - Use `--feature bevy/bevy_dev_tools` flag when using the `cargo run` command:
|
|
///
|
|
/// `cargo run --features bevy/bevy_dev_tools`
|
|
///
|
|
/// - Add the `bevy_dev_tools` feature to the bevy dependency in your `Cargo.toml` file:
|
|
///
|
|
/// `features = ["bevy_dev_tools"]`
|
|
///
|
|
/// Note: The third method is not recommended, as it requires you to remove the feature before
|
|
/// creating a build for release to the public.
|
|
#[derive(Default)]
|
|
pub struct DevToolsPlugin;
|
|
|
|
impl Plugin for DevToolsPlugin {
|
|
fn build(&self, _app: &mut App) {}
|
|
}
|