2024-03-23 02:22:52 +00:00
|
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
2024-03-27 03:30:08 +00:00
|
|
|
#![forbid(unsafe_code)]
|
2024-03-25 18:52:50 +00:00
|
|
|
#![doc(
|
|
|
|
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
|
|
|
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
|
|
|
)]
|
2024-03-23 02:22:52 +00:00
|
|
|
|
2024-03-06 20:33:05 +00:00
|
|
|
//! This crate provides additional utilities for the [Bevy game engine](https://bevyengine.org),
|
|
|
|
//! focused on improving developer experience.
|
|
|
|
|
|
|
|
use bevy_app::prelude::*;
|
2024-03-11 19:26:14 +00:00
|
|
|
|
2024-03-06 20:33:05 +00:00
|
|
|
#[cfg(feature = "bevy_ci_testing")]
|
|
|
|
pub mod ci_testing;
|
2024-04-03 01:29:06 +00:00
|
|
|
|
2024-03-11 19:26:14 +00:00
|
|
|
pub mod fps_overlay;
|
2024-03-06 20:33:05 +00:00
|
|
|
|
Add a gizmo-based overlay to show UI node outlines (Adopted) (#11237)
# Objective
- This is an adopted version of #10420
- The objective is to help debugging the Ui layout tree with helpful
outlines, that can be easily enabled/disabled
## Solution
- Like #10420, the solution is using the bevy_gizmos in outlining the
nodes
---
## Changelog
### Added
- Added debug_overlay mod to `bevy_dev_tools`
- Added bevy_ui_debug feature to `bevy_dev_tools`
## How to use
- The user must use `bevy_dev_tools` feature in TOML
- The user must use the plugin UiDebugPlugin, that can be found on
`bevy::dev_tools::debug_overlay`
- Finally, to enable the function, the user must set
`UiDebugOptions::enabled` to true
Someone can easily toggle the function with something like:
```rust
fn toggle_overlay(input: Res<ButtonInput<KeyCode>>, options: ResMut<UiDebugOptions>) {
if input.just_pressed(KeyCode::Space) {
// The toggle method will enable if disabled and disable if enabled
options.toggle();
}
}
```
Note that this feature can be disabled from dev_tools, as its in fact
behind a default feature there, being the feature bevy_ui_debug.
# Limitations
Currently, due to limitations with gizmos itself, it's not possible to
support this feature to more the one window, so this tool is limited to
the primary window only.
# Showcase
![image](https://github.com/bevyengine/bevy/assets/126117294/ce9d70e6-0a57-4fa9-9753-ff5a9d82c009)
Ui example with debug_overlay enabled
![image](https://github.com/bevyengine/bevy/assets/126117294/e945015c-5bab-4d7f-9273-472aabaf25a9)
And disabled
---------
Co-authored-by: Nicola Papale <nico@nicopap.ch>
Co-authored-by: Pablo Reinhardt <pabloreinhardt@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-03-18 18:11:06 +00:00
|
|
|
#[cfg(feature = "bevy_ui_debug")]
|
2024-03-26 19:40:55 +00:00
|
|
|
pub mod ui_debug_overlay;
|
Add a gizmo-based overlay to show UI node outlines (Adopted) (#11237)
# Objective
- This is an adopted version of #10420
- The objective is to help debugging the Ui layout tree with helpful
outlines, that can be easily enabled/disabled
## Solution
- Like #10420, the solution is using the bevy_gizmos in outlining the
nodes
---
## Changelog
### Added
- Added debug_overlay mod to `bevy_dev_tools`
- Added bevy_ui_debug feature to `bevy_dev_tools`
## How to use
- The user must use `bevy_dev_tools` feature in TOML
- The user must use the plugin UiDebugPlugin, that can be found on
`bevy::dev_tools::debug_overlay`
- Finally, to enable the function, the user must set
`UiDebugOptions::enabled` to true
Someone can easily toggle the function with something like:
```rust
fn toggle_overlay(input: Res<ButtonInput<KeyCode>>, options: ResMut<UiDebugOptions>) {
if input.just_pressed(KeyCode::Space) {
// The toggle method will enable if disabled and disable if enabled
options.toggle();
}
}
```
Note that this feature can be disabled from dev_tools, as its in fact
behind a default feature there, being the feature bevy_ui_debug.
# Limitations
Currently, due to limitations with gizmos itself, it's not possible to
support this feature to more the one window, so this tool is limited to
the primary window only.
# Showcase
![image](https://github.com/bevyengine/bevy/assets/126117294/ce9d70e6-0a57-4fa9-9753-ff5a9d82c009)
Ui example with debug_overlay enabled
![image](https://github.com/bevyengine/bevy/assets/126117294/e945015c-5bab-4d7f-9273-472aabaf25a9)
And disabled
---------
Co-authored-by: Nicola Papale <nico@nicopap.ch>
Co-authored-by: Pablo Reinhardt <pabloreinhardt@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-03-18 18:11:06 +00:00
|
|
|
|
2024-06-04 11:44:34 +00:00
|
|
|
pub mod states;
|
|
|
|
|
2024-03-06 20:33:05 +00:00
|
|
|
/// 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
|
2024-06-17 17:22:01 +00:00
|
|
|
/// along with any other development tools you might be using:
|
2024-03-06 20:33:05 +00:00
|
|
|
///
|
|
|
|
/// ```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.
|
2024-07-16 01:14:33 +00:00
|
|
|
#[derive(Default)]
|
2024-03-06 20:33:05 +00:00
|
|
|
pub struct DevToolsPlugin;
|
|
|
|
|
|
|
|
impl Plugin for DevToolsPlugin {
|
Refactor `ci_testing` and separate it from `DevToolsPlugin` (#13513)
# Objective
- We use
[`ci_testing`](https://dev-docs.bevyengine.org/bevy/dev_tools/ci_testing/index.html)
to specify per-example configuration on when to take a screenshot, when
to exit, etc.
- In the future more features may be added, such as #13512. To support
this growth, `ci_testing` should be easier to read and maintain.
## Solution
- Convert `ci_testing.rs` into the folder `ci_testing`, splitting the
configuration and systems into `ci_testing/config.rs` and
`ci_testing/systems.rs`.
- Convert `setup_app` into the plugin `CiTestingPlugin`. This new plugin
is added to both `DefaultPlugins` and `MinimalPlugins`.
- Remove `DevToolsPlugin` from `MinimalPlugins`, since it was only used
for CI testing.
- Clean up some code, add many comments, and add a few unit tests.
## Testing
The most important part is that this still passes all of the CI
validation checks (merge queue), since that is when it will be used the
most. I don't think I changed any behavior, so it should operate the
same.
You can also test it locally using:
```shell
# Run the breakout example, enabling `bevy_ci_testing` and loading the configuration used in CI.
CI_TESTING_CONFIG=".github/example-run/breakout.ron" cargo r --example breakout -F bevy_ci_testing
```
---
## Changelog
- Added `CiTestingPlugin`, which is split off from `DevToolsPlugin`.
- Removed `DevToolsPlugin` from `MinimalPlugins`.
## Migration Guide
Hi maintainers! I believe `DevToolsPlugin` was added within the same
release as this PR, so I don't think a migration guide is needed.
`DevToolsPlugin` is no longer included in `MinimalPlugins`, so you will
need to remove it manually.
```rust
// Before
App::new()
.add_plugins(MinimalPlugins)
.run();
// After
App::new()
.add_plugins(MinimalPlugins)
.add_plugins(DevToolsPlugin)
.run();
```
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: François Mockers <francois.mockers@vleue.com>
2024-05-26 22:32:36 +00:00
|
|
|
fn build(&self, _app: &mut App) {}
|
2024-03-06 20:33:05 +00:00
|
|
|
}
|