Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using bevy_gizmos feature with default-features=false renders nothing (requires extra bevy_pbr feature) #10984

Closed
bonsairobo opened this issue Dec 14, 2023 · 2 comments · Fixed by #11296
Labels
A-Gizmos Visual editor and debug gizmos A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@bonsairobo
Copy link
Contributor

Bevy version

0.12

What you did

Tried to use bevy_gizmos with the following bevy dependency configuration:

[dependencies.bevy]
version = "0.12"
default-features = false
features = ["bevy_gizmos"]

What went wrong

Gizmos were not drawn.

Additional information

The fix was to add the bevy_pbr feature:

[dependencies.bevy]
version = "0.12"
default-features = false
features = ["bevy_gizmos", "bevy_pbr"]

I think we just need to add an explicit dependency on bevy_pbr here:

bevy/Cargo.toml

Line 132 in ca1874e

bevy_gizmos = ["bevy_internal/bevy_gizmos"]

@bonsairobo bonsairobo added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 14, 2023
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy A-Rendering Drawing game state to the screen A-Gizmos Visual editor and debug gizmos and removed S-Needs-Triage This issue needs to be labelled labels Dec 14, 2023
@tim-blackbird
Copy link
Contributor

Always adding bevy_pbr as a feature would prevent users that only need bevy_sprite from disabling it, and vice versa.

@BD103
Copy link
Member

BD103 commented Jan 1, 2024

Since gizmos requires either bevy_pbr or bevy_sprite, perhaps a compile error could be thrown when neither is enabled.

#[cfg(all(not(feature = "bevy_pbr"), not(feature = "bevy_sprite")))]
compile_error!("bevy_gizmos requires either bevy_pbr or bevy_sprite. Please enable one as an optional dependency.");

github-merge-queue bot pushed a commit that referenced this issue Jan 14, 2024
…11296)

# Objective

- `bevy_gizmos` cannot work if both `bevy_sprite` and `bevy_pbr` are
disabled.
- It silently fails to render, making it difficult to debug.
- Fixes #10984

## Solution

- Log an error message when `GizmoPlugin` is registered.

## Alternatives

I chose to log an error message, since it seemed the least intrusive of
potential solutions. Some alternatives include:

- Choosing one dependency as the default, neglecting the other. (#11035)
- Raising a compile error when neither dependency is enabled. ([See my
original
comment](#10984 (comment)))
- Raising a compile warning using a macro hack. ([Pre-RFC - Add
compile_warning!
macro](https://internals.rust-lang.org/t/pre-rfc-add-compile-warning-macro/9370/7?u=bd103))
- Logging a warning instead of an error.
- _This might be the better option. Let me know if I should change it._

---

## Changelog

- `bevy_gizmos` will now log an error if neither `bevy_pbr` nor
`bevy_sprite` are enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Gizmos Visual editor and debug gizmos A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
4 participants