Skip to content

Commit

Permalink
Improve B0004 warning description
Browse files Browse the repository at this point in the history
  • Loading branch information
nicopap committed Sep 5, 2022
1 parent f9e4390 commit e5db0f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_hierarchy/src/valid_parent_check_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
/// which parent hasn't a `T` component.
///
/// See [`check_hierarchy_component_has_valid_parent`] for details.
pub struct ValidParentCheckPlugin<T>(PhantomData<fn() -> T>);
pub struct ValidParentCheckPlugin<T: Component>(PhantomData<fn() -> T>);
impl<T: Component> Default for ValidParentCheckPlugin<T> {
fn default() -> Self {
Self(PhantomData)
Expand Down
15 changes: 11 additions & 4 deletions errors/B0004.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ A runtime warning.
An [`Entity`] with a hierarchy-inherited component has a [`Parent`]
without the hierarchy-inherited component in question.

The hierarchy-inherited components are:
The hierarchy-inherited components defined in bevy include:

- [`ComputedVisibility`]
- [`GlobalTransform`]

For example, the following code will cause a warning to be emitted:
Third party plugins may also define their own hierarchy components, so
read carefully the warning message and pay attention to the exact type
of the missing component.

To fix this warning, add the missing hierarchy component to all ancestors
of entities with the hierarchy component you wish to use.

The following code will cause a warning to be emitted:

```rust,no_run
use bevy::prelude::*;
Expand Down Expand Up @@ -55,7 +62,7 @@ Since the cube is spawned as a child of an entity without the
[`ComputedVisibility`] component, it will not be visible at all.

To fix this, you must use [`SpatialBundle`] over [`TransformBundle`],
as follow:
as follows:

```rust,no_run
use bevy::prelude::*;
Expand Down Expand Up @@ -100,7 +107,7 @@ However, when a parent [`GlobalTransform`] is missing,
it will simply prevent all transform propagation,
including when updating the [`Transform`] component of the child.

You will most likely encouter this warning when loading a scene
You will most likely encounter this warning when loading a scene
as a child of a pre-existing [`Entity`] that does not have the proper components.

[`ComputedVisibility`]: https://docs.rs/bevy/*/bevy/render/view/struct.ComputedVisibility.html
Expand Down

0 comments on commit e5db0f9

Please sign in to comment.