-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
What problem does this solve or what need does it fill?
Many built-in systems (e.g. extract_text2d_sprite()
query a core component they want to update (e.g. Text
) with an associated unconditional Visibility
component. If removed, the system doesn't run on the Entity
. However, most components (and especially the ones directly related to rendering) should be assumed visible by default. The ability to dynamically control the visibility of a render item should be an additional opt-in feature, not a default one.
What solution would you like?
Replace Visibility
with Option<Visibility>
in the query of most built-in systems, and treat None
as Visibility::is_visible == true
.
if !maybe_visibility.map_or(true, |vis| vis.is_visible) {
continue; // skip this entity
}
What alternative(s) have you considered?
Do nothing. This forces adding many unused Visibility
components for all entities that are never going to be hidden (they might be deleted, but not dynamically shown/hidden).
Additional context
The more "mandatory" components in a built-in system, the more difficult it is to reuse the built-in Bevy components. I'm trying to use Text
to render some text, but with some properties (notably, the position, but also the visibility) controlled by my own framework. I could go rewrite from scratch a text rendering pipeline, but it feels like reusing the existing one is probably the best course of action. However currently the extract_text2d_sprite()
system forces adding 3 extra components in addition of Text
, which I argue is too much and at least Visibility
should be optional (if not others; alignment could also be made optional for the cases where there's no need to align).