bevy/errors
Nicola Papale 6c5403cf47 Add warning when a hierarchy component is missing (#5590)
# Objective

A common pitfall since 0.8 is the requirement on `ComputedVisibility`
being present on all ancestors of an entity that itself has
`ComputedVisibility`, without which, the entity becomes invisible.

I myself hit the issue and got very confused, and saw a few people hit
it as well, so it makes sense to provide a hint of what to do when such
a situation is encountered.

- Fixes #5849
- Closes #5616
- Closes #2277 
- Closes #5081

## Solution

We now check that all entities with both a `Parent` and a
`ComputedVisibility` component have parents that themselves have a
`ComputedVisibility` component.

Note that the warning is only printed once.

We also add a similar warning to `GlobalTransform`.

This only emits a warning. Because sometimes it could be an intended
behavior.

Alternatives:
- Do nothing and keep repeating to newcomers how to avoid recurring
  pitfalls
- Make the transform and visibility propagation tolerant to missing
  components (#5616)
- Probably archetype invariants, though the current draft would not
  allow detecting that kind of errors

---

## Changelog

- Add a warning when encountering dubious component hierarchy structure


Co-authored-by: Nicola Papale <nicopap@users.noreply.github.com>
2022-09-19 16:12:11 +00:00
..
src Add warning when a hierarchy component is missing (#5590) 2022-09-19 16:12:11 +00:00
B0001.md ParamSet for conflicting SystemParam:s (#2765) 2022-03-29 23:39:38 +00:00
B0002.md Replace old renderer with new renderer (#3312) 2021-12-14 03:58:23 +00:00
B0003.md Make Resource trait opt-in, requiring #[derive(Resource)] V2 (#5577) 2022-08-08 21:36:35 +00:00
B0004.md Add warning when a hierarchy component is missing (#5590) 2022-09-19 16:12:11 +00:00
Cargo.toml Add readme to errors crate and clean up cargo files (#3125) 2021-11-13 23:06:48 +00:00
README.md Add readme to errors crate and clean up cargo files (#3125) 2021-11-13 23:06:48 +00:00

Bevy Error Codes

This crate lists and tests explanations and examples of Bevy's error codes.

For the latest Bevy release, you can find a rendered version of the error code descriptions at bevyengine.org/learn/errors.