Skip to content

Commit e5db0f9

Browse files
committed
Improve B0004 warning description
1 parent f9e4390 commit e5db0f9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

crates/bevy_hierarchy/src/valid_parent_check_plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ where
7070
/// which parent hasn't a `T` component.
7171
///
7272
/// See [`check_hierarchy_component_has_valid_parent`] for details.
73-
pub struct ValidParentCheckPlugin<T>(PhantomData<fn() -> T>);
73+
pub struct ValidParentCheckPlugin<T: Component>(PhantomData<fn() -> T>);
7474
impl<T: Component> Default for ValidParentCheckPlugin<T> {
7575
fn default() -> Self {
7676
Self(PhantomData)

errors/B0004.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ A runtime warning.
55
An [`Entity`] with a hierarchy-inherited component has a [`Parent`]
66
without the hierarchy-inherited component in question.
77

8-
The hierarchy-inherited components are:
8+
The hierarchy-inherited components defined in bevy include:
99

1010
- [`ComputedVisibility`]
1111
- [`GlobalTransform`]
1212

13-
For example, the following code will cause a warning to be emitted:
13+
Third party plugins may also define their own hierarchy components, so
14+
read carefully the warning message and pay attention to the exact type
15+
of the missing component.
16+
17+
To fix this warning, add the missing hierarchy component to all ancestors
18+
of entities with the hierarchy component you wish to use.
19+
20+
The following code will cause a warning to be emitted:
1421

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

5764
To fix this, you must use [`SpatialBundle`] over [`TransformBundle`],
58-
as follow:
65+
as follows:
5966

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

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

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

0 commit comments

Comments
 (0)